I created a container using following command:
docker run -itd --name jkdb -e POSTGRES_PASSWORD=123 -v /home/lchang/jkrug/data:/var/lib/postgresql/data -p 5532:5432 -d postgres
I checked in container and psql does listen to 5432 in container.
However, when I try to connect from my host by following command, I got an error:
psql -p 5532 -U postgres
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5532"?
I searched many posts but none of them is same with my case. Any idea? Thanks!
It does not make any sense but after I specify the host IP is 0.0.0.0
I can connect to docker.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With