Contact Form

Name

Email *

Message *

Cari Blog Ini

Docker Postgresql Pgadmin4

```html

Install PostgreSQL and pgAdmin 4 on Docker

Introduction

In this article, we will walk through the steps of installing PostgreSQL and pgAdmin 4 in a Docker environment.

What is PostgreSQL?

PostgreSQL is an open-source, powerful, and popular object-relational database management system (ORDBMS). It is widely used for various applications, including web development, data warehousing, and geographic information systems (GIS).

What is pgAdmin 4?

PgAdmin 4 is a web-based administration tool for the PostgreSQL database. It provides a graphical user interface (GUI) to manage databases, tables, users, and other objects. It offers various features to help simplify database administration.

Why use Docker?

Docker is a platform that enables users to create, deploy, and manage containerized applications. It provides a consistent and isolated environment that helps streamline the development and deployment process. By using Docker, we can easily set up and manage PostgreSQL and pgAdmin 4 without worrying about the underlying infrastructure.

Prerequisites

Before we proceed, ensure you have the following prerequisites: * Docker installed on your system * A user with sudo privileges

Steps to Install PostgreSQL and pgAdmin 4 on Docker

Follow these steps to install PostgreSQL and pgAdmin 4 on Docker: 1. **Create a Docker network:** ``` docker network create postgres-net ``` 2. **Run the PostgreSQL container:** ``` docker run -d \ --name postgres \ --network postgres-net \ -p 5432:5432 \ -e POSTGRES_USER=postgres \ -e POSTGRES_PASSWORD=postgres \ postgres ``` 3. **Run the pgAdmin container:** ``` docker run -d \ --name pgadmin \ --network postgres-net \ -p 8080:80 \ -e PGADMIN_DEFAULT_EMAIL=admin@example.com \ -e PGADMIN_DEFAULT_PASSWORD=admin \ --link postgres:postgres \ dpage/pgadmin4 ``` 4. **Access the pgAdmin web interface:** Once the containers are running, you can access the pgAdmin web interface by opening your browser and navigating to `http://localhost:8080`. 5. **Connect to the PostgreSQL database:** Log in to the pgAdmin web interface using the default username (`admin@example.com`) and password (`admin`). 6. **Create a new database:** Right-click on the 'Databases' node in the left panel and select 'Create' > 'Database'. 7. **Configure the database:** Enter a name for the database and select the PostgreSQL server you want to use. 8. **Manage your database:** Once the database is created, you can use pgAdmin to manage it. You can create tables, views, indexes, and other objects.

Additional Notes and Tips

* You can change the default passwords for PostgreSQL and pgAdmin by modifying the `POSTGRES_PASSWORD` and `PGADMIN_DEFAULT_PASSWORD` environment variables when running the containers. * You can access the PostgreSQL command-line interface by executing `docker exec -it postgres /bin/bash`. * You can view the logs of the PostgreSQL container by executing `docker logs postgres`. * If you encounter any issues, check the Docker documentation or search for specific error messages online. ```


Comments