Closed khaledJabr closed 5 months ago
Hi,
Postgres is running in a container in Docker Compose. It wouldn't use your local postgres DB, at least not by default.
If you want to use your local Postgres you can change your .env
file from #export POSTGRES_HOST=postgres
to export POSTGRES_HOST=host.docker.internal:5432
and then update the other env vars near there to use your local DB's credentials. Then you can remove Postgres from the Docker Compose file if you want but that's technically optional.
The above is optional though, this project includes everything you need to run Postgres through Docker.
Thank you for your timely response. I went over your docker best practices article and I think the setup makes a lot more sense now.
Hello,
Thanks again for the great repo. I have a question about how you setup postgres for this project. I don't have a fullstack/djano background and I was not able to find the answer anywhere I looked.
When doing the very first migration, the current setup does not recognize my local postgres database so it throws an error saying that my target db name, lets call it
testdb
, does not exist. Even if I create this database in my local postgres server, is still not recognized.It only works when I docker exec into the postgres docker image and create the database in the running psql instance.
I also tried updated the docker-compose file to point from
"postgres:/var/lib/postgresql/data"
to my locatl data directory (/var/lib/postgresql/16/main
) but still the same problem.do you have an idea why is this happening? is it possible to post it at my local postgres ?
edit:
im using ubuntu 22, postgres 16.2