postgresqldocker

Can not connect to Postgres Container from pgAdmin


related posts: 1) docker postgres pgadmin local connection

2) https://coderwall.com/p/qsr3yq/postgresql-with-docker-on-os-x (in the example "Name" entry is not filled in)

there are two ways to complete this task, I use official postgres

METHOD 1:

and runs it with

sudo docker run --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword -p 5432:5432 -d postgres

then connect with

Name: postgres
Host: localhost
Port: 5432
user
pass
...

METHOD 2:

starts with

sudo docker run --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword -d postgres

and then check the ip of container

sudo docker inspect

say result

172.17.42.1

then connect with pgAdmin tab Properties filled info

Name: postgres
Host: 172.17.42.1
Port: 5432
user
pass
...

Solution

  • Since you're mapping the port 5432 on the container to the same port on host with -p 5432:5432 in your docker run statement, try connecting pgadmin to port 5432 on the host instead of the container.