Contact Form

Name

Email *

Message *

Cari Blog Ini

Author Details

Pgadmin Docker Compose

Deploying PostgreSQL and pgAdmin 4 in a Docker Environment

Introduction

In this article, we will guide you through the process of installing and running PostgreSQL and pgAdmin 4 in a Docker container. Docker is a platform that allows you to package and run applications in isolated environments, making it an ideal tool for deploying and managing database services.

Deploying PostgreSQL

To deploy PostgreSQL in Docker, you can use the official Docker image. You can pull the image using the following command: ``` docker pull postgres:latest ``` Once the image is pulled, you can create and start a PostgreSQL container using the following command: ``` docker run -d --name postgres -p 5432:5432 -e POSTGRES_PASSWORD=my-password postgres:latest ``` In this command, we are: - Assigning the name "postgres" to the container - Mapping the container's port 5432 to the host's port 5432 - Setting the PostgreSQL password to "my-password"

Deploying pgAdmin 4

To deploy pgAdmin 4 in Docker, you can use the official Docker image. You can pull the image using the following command: ``` docker pull dpage/pgadmin4 ``` Once the image is pulled, you can create and start a pgAdmin 4 container using the following command: ``` docker run -d --name pgadmin -p 8080:80 -e PGADMIN_DEFAULT_EMAIL=my-email -e PGADMIN_DEFAULT_PASSWORD=my-password dpage/pgadmin4 ``` In this command, we are: - Assigning the name "pgadmin" to the container - Mapping the container's port 80 to the host's port 80 - Setting the pgAdmin 4 default email address to "my-email" - Setting the pgAdmin 4 default password to "my-password"

Accessing PostgreSQL and pgAdmin 4

Once the containers are up and running, you can access PostgreSQL using a database client such as psql or DBeaver. To connect to the database, use the following connection parameters: - Host: localhost - Port: 5432 - Username: postgres - Password: my-password - Database: postgres You can access pgAdmin 4 by visiting http://localhost:8080 in your browser.

Conclusion

In this article, we have walked you through the steps of installing and running PostgreSQL and pgAdmin 4 in a Docker environment. This provides a convenient and isolated way to manage your database services, making it an ideal solution for development and production environments.


Comments