I am using Docker on Mac. I run container1 with Postgres, publishing port 5432. From the host, I can connect using psql: psql -h localhost -d postgres -U postgres -W
.
I then run container2. From container2, I can run ping host.docker.internal
and see that it's working. However, I cannot access Postgres with the same psql command.
Why doesn't this work, and what can I do to make it work? I thought that, because I can access the host from within container2, trying to connect to port 5432 would be mapped to container1.