Docker Community Forums

Share and learn in the Docker community.

Docker network with Django, Nginx, Postgres

(Meleiyu) #1

I have a Docker network with Django, Nginx, and Postgres. I’m trying to set an old project up on docker for future development as a way to get more familiar with docker. I’ve been able to figure everything out until I switched from SQLite to MySQL/Postgres. MySQL was giving me errors about python’s sha_2_connection import and even when I changed the my.cnf to use native mysql encryption it persisted. Postgres is working but when I try to run the migrate command Django cannot find the database.

In my compose file I specify the port 3306 but in the console postgres is running on 5432, the default. I’ve tried setting the django settings for the database host to db (the docker service name), localhost,,, etc. The error will say “Is the database listening on port 5432?” And docker container ls shows postgres on>5432

I’m very confused by this. Any assistance would be appreciated as I’d like to begin using docker for more things.

Here is my compose file:

(Meleiyu) #2

Looks like I needed to set the HOST in the Django config to “db”