Skip to content

PgAdmin 4 docker

PgAdmin 4 docker

PgAdmin 4 docker

PgAdmin 4 docker container has exposed port 80 and 443 by default. You can check the Dockerfile here

So the port mapping parameter in the command has to be updated (-p host_port: container_port)

Below is the updated command to access pgadmin4 via http (port 80)

docker run -p 5050:80 -e "PGADMIN_DEFAULT_EMAIL=myemail@gmail.com" -e "PGADMIN_DEFAULT_PASSWORD=a12345678" -d  dpage/pgadmin4

After starting the container you should be able to access it via http://localhost:5050

Adding docker db server

We will need to look for the IP address of the PostgreSQL container on our host, you can run this command for it:

docker inspect dev-postgres -f "{{json .NetworkSettings.Networks }}"
docker inspect return low-level information of Docker objects, in this case, the ‘dev-postgres’ instance’s IP Adress. The -f parameter is to format the output as a JSON given a Go template. The output should look like this:
{
    "bridge":
 {
           "IPAMConfig":null,
           "Links":null,
           "Aliases":null,
           "NetworkID":"60c21f5cfcaaff424a0e4a22463dc8f9a285993de04e7ac19ce5fd96bba56a47",
           "EndpointID":"be6e45b659c30bd12aa766d7003a2887607053684b68574e426f8823104b18a2",
           "Gateway":"172.17.0.1",
           "IPAddress":"172.17.0.2",
           "IPPrefixLen":16,
           "IPv6Gateway":"",
           "GlobalIPv6Address":"",
           "GlobalIPv6PrefixLen":0,
           "MacAddress":"02:42:ac:11:00:02",
           "DriverOpts":null
 }
}

Copy the IPAddress value into the clipboard, which is 172.17.0.2 in my case, you will need to define the connection in the pgAdmin tool.