How to install pgadmin4 with docker

We want PostgreSQL in a container and pgadmin4 in another container. And we want to connect the pgadmin4 container to the PostgreSQL container.

We do

$ sudo docker run -p 80:80 \
  --link postgres11:postgres11 \
  --name pgadmin_4pgdocker \
  -e "" \
  -d dpage/pgadmin4

80:80 means that the port 80 of the container is tunneled to the port 80 of the host.

–link postgres11:postgres11 means that we link the pgadmin4 container to the postgres11 container. Remember that we wrote in the definition of the postgres11 container the name of the host :

--name postgres11

and then we open our browser on, we give the username/password as defined above and when create a server, we give as host name postgres11


For the host name, we give postgres11 instead of !

and then…


We can set about tackling the work !

And the next time we reboot, we have a look on our containers

sudo docker ps -a

that gives

CONTAINER ID   IMAGE           COMMAND                CREATED       STATUS                        
PORTS                        NAMES
c8f82e1fd7f6   dpage/pgadmin4  "/"       27 hours ago  Exited (255) 10 minutes ago>80/tcp, 443/tcp  jolly_mendel
c9159dae8aae   postgres        "docker-entrypoint.s…" 27 hours ago  Up About a minute    >5432/tcp       postgres11

They are of course there and their CONTAINER ID are the same. By the way, the creators of containers are used to give them poetical names like jolly_mendel.

And we restart them

$ sudo docker start c9159dae8aae
$ sudo docker start c8f82e1fd7f6

So nice !

And if we want that pgadmin4 reaches the cluster located on the host, we do

$ sudo docker run \
  -d \
  --rm \
  --net=host \
  -e "" \
  --name pgadmin_4_local dpage/pgadmin4                                      

We have to stop pgadmin_4pgdocker before starting the previous command.

At this very moment, I don’t know how to manage two pgadmin4 containers simultaneously.

Or to have two clusters in pgadmin4 : one for the PostgreSQL cluster in the container and one for the PostgreSQL on the host.

A bit patience…

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s