Home > Back-end >  connecting pgadmin container and postgres container
connecting pgadmin container and postgres container

Time:01-23

using UBUNTO OS
have downloaded the postgres and pgadmin images and ran the containers

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

pgadmin command
sudo docker run --name pgadmin --link some-postgres:postgres -p 80:80 -d fenglc/pgadmin4

then ensured that both the containers are running like below

sudo docker container ls 
CONTAINER ID   IMAGE             COMMAND                  CREATED              STATUS              PORTS                                         NAMES
3bf1e2bcf5e7   fenglc/pgadmin4   "docker-entrypoint.s…"   About a minute ago   Up About a minute   0.0.0.0:80->80/tcp, :::80->80/tcp, 5050/tcp   pgadmin
b21c2bda2cff   postgres          "docker-entrypoint.s…"   13 minutes ago       Up 13 minutes       0.0.0.0:5432->5432/tcp, :::5432->5432/tcp     some-postgres

now issue is when trying to access pgadmin @ localhost/ or localhost:80 it is showing connection reset error
error accessing pgadmin

also below is the result of docker inspect pgadmin

"NetworkSettings": { "Bridge": "", "SandboxID": "fb4f3dcf1eed267055060b945ba8fb4bff372873d1cc179a24c934c883c1d100", "HairpinMode": false, "LinkLocalIPv6Address": "", "LinkLocalIPv6PrefixLen": 0, "Ports": { "5050/tcp": null, "80/tcp": [ { "HostIp": "0.0.0.0", "HostPort": "80" }, { "HostIp": "::", "HostPort": "80" } ] }, "SandboxKey": "/var/run/docker/netns/fb4f3dcf1eed", "SecondaryIPAddresses": null, "SecondaryIPv6Addresses": null, "EndpointID": "879f386a86712d2699373ef8667b07984db337e7267a2381da69cdbc5405251e", "Gateway": "XXXX.XX.0.1", "GlobalIPv6Address": "",

Regards, Ashish

CodePudding user response:

fengic/pgadmin4 listens on port 5050. Not on port 80. So your docker run command needs to be

sudo docker run --name pgadmin --link some-postgres:postgres -p 80:5050 -d fenglc/pgadmin4

Then you should be able to access pgadmin on localhost port 80.

Be aware that links are an outdated way of connecting containers and the feature may be removed at some point. The recommended way to connect containers is using docker networks.

  • Related