Docker container for Postgres 9.1 not exposing port 5432 to host
Run the postgre image with the correct Port Mapping using -p <host_port>:<container_port>
:
docker run --same-options-as-step-one -d -p 5432:5432 postgres:9.1
It's 2018 and I just had a similar problem. The solution for me seemed to be with the order of props to docker. e.g. this resulted in no port being exposed;
docker run -d --name posttest postgres:alpine -e POSTGRES_PASSWORD=fred -p 5432:5432
while this worked fine (image exposed port 5432 as expected);
docker run --name posttest -d -p 5432:5432 -e POSTGRES_PASSWORD=fred postgres:alpine
Your docker host is a virtual machine, which has it's own IP adddres. You can detect this IP address by entering the following command:
docker-machine ip
The answer will be something like 192.168.99.100
When you have mapped the ports using the -p 5432:5432 switch, you will be able to connect to postgres with any tool from your dev machine using the IP address mentioned.