Install pgAdmin using Docker Compose

In the previous tutorial, I showed you how to install pgAdmin to work with PostgreSQL server on macOS. In this tutorial, I will show you how to install this tool using Docker Compose!

The official Docker Image of pgAdmin on Docker Hub is located at https://hub.docker.com/r/dpage/pgadmin4/, and you can use the latest version to install pgAdmin with the Docker Compose file with the following content:

There are 2 environment variables that we must declare, which are PGADMIN_DEFAULT_EMAIL and PGADMIN_DEFAULT_PASSWORD. This is the credential information to log in to pgAdmin.

Another environment variable will also be required if we do not declare the PGADMIN_DEFAULT_PASSWORD environment variable, which is PGADMIN_DEFAULT_PASSWORD_FILE. The PGADMIN_DEFAULT_PASSWORD_FILE variable is used to specify the file containing the Docker secret password information. We use the password information in this Docker secret file to log in.

Details about the environment variables that you can declare to use with pgAdmin’s Docker Image, you can read more here.

Run the command “docker compose up” in the directory containing the Docker Compose file with the above content, you will see the content similar to the following:

Now request to http://localhost:8888, you will see the following result:

Log in with the credential information you declared in the Docker Compose file, you will see the same result as me as follows:

So we have successfully installed pgAdmin using Docker Compose!

Add Comment