I am running a Postgres SQL database container with following command:
docker run --name db -p 5432:5432 -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -v pg Of course I have changed the 'localhost' to 'db' since I am trying to connect with this container. when I try to connect to the container database I get the following error:
psycopg2.OperationalError: could not translate host name "db" to address: Name or service not known I cant use here Docker compose in this context ( I know how to run it though ). What else I need to add in my docker command so that I can connect from python ?