I put together a Rails dev environment by following instructions from https://docs.docker.com/compose/rails/
It works, but I am unable to connect to the Postgres server from the host machine. I am running macOS High Sierra. When I run docker container ls
I see 5432/tcp
as the port for the Postgres container. Note that there's not IP listed in front of 5432. When I run docker network inspect <postgress_container_ID>
I get 172.18.0.2 as the IP.
But when I run psql -h 172.18.0.2 -p 5432 -U postgres
I get
xpsql: could not connect to server: Operation timed out
Is the server running on host "172.18.0.2" and accepting
TCP/IP connections on port 5432?
What am I doing wrong?