DEV Community

Nickson Elauriche Toho
Nickson Elauriche Toho

Posted on

How to run PgAdmin4 with Docker

Running the docker run command for pgAdmin 4 will start a Docker container with the pgAdmin 4 application. To achieve this, you need to have Docker installed on your system. If you don't have Docker installed, you can download it from the official Docker website: https://www.docker.com/get-started

Here is a basic docker run command to start pgAdmin 4:

docker run --name pgadmin-container -p 0.0.0.0:5050:80 -e PGADMIN_DEFAULT_EMAIL=admin@domain.com -e PGADMIN_DEFAULT_PASSWORD=admin -e PGADMIN_LISTEN_ADDRESS=0.0.0.0 -d dpage/pgadmin4

Enter fullscreen mode Exit fullscreen mode

Let’s break down the command:

  • -p 0.0.0.0:5050:80: This binds the container's port 80 to all available network interfaces on the host machine (0.0.0.0). This makes pgAdmin 4 accessible from anywhere.

  • -e PGADMIN_LISTEN_ADDRESS=0.0.0.0: This environment variable sets pgAdmin 4 to listen on all available network interfaces.

---name my_pgadmin4: This option gives a custom name ("my_pgadmin4") to the Docker container. You can choose a different name if you prefer.

  • -e PGADMIN_DEFAULT_EMAIL=user@example.com: This sets the default email for the initial login.

  • -e PGADMIN_DEFAULT_PASSWORD=admin: This sets the default password for the initial login.

  • -d: This runs the container in detached mode, meaning it runs in the background.

  • dpage/pgadmin4: This is the Docker image for pgAdmin 4. If the image is not already downloaded, Docker will automatically pull it from the Docker Hub.

-After running this command, you should be able to access pgAdmin 4 by opening your web browser and navigating to http://localhost:5050. Use the email and password specified in the docker run command to log in.

Remember to adjust the parameters based on your preferences and requirements. Also, ensure that the chosen port is not already in use on your host machine.

Top comments (0)