Docker Compose Script for PostgreSQL and pgAdmin4
Introduction
In this guide, we will guide you through the process of creating a PostgreSQL server and pgAdmin4 using Docker Compose. By following these steps, you can easily set up a development environment for working with PostgreSQL.
Prerequisites
Before you begin, ensure you have the following installed:
- Docker
- Docker Compose
Create the Docker Compose Script
Create a file named docker-compose.yml with the following content:
``` version: '3' services: postgres: image: 'postgres:latest' ports: - '5432:5432' environment: - POSTGRES_USER=postgres - POSTGRES_PASSWORD=postgres - POSTGRES_DB=postgres pgadmin4: image: 'dpage/pgadmin4' ports: - '8080:80' environment: - PGADMIN_DEFAULT_EMAIL=admin@example.com - PGADMIN_DEFAULT_PASSWORD=admin ```Start the Containers
To start the containers, run the following command:
``` docker-compose up -d ```Access PostgreSQL
You can access the PostgreSQL server using the following command:
``` docker exec -it postgres psql -U postgres -d postgres ```Access pgAdmin4
You can access pgAdmin4 by visiting the following URL in your browser:
``` http://localhost:8080 ```Conclusion
In this tutorial, we have shown you how to set up a PostgreSQL server and pgAdmin4 using Docker Compose. This setup is ideal for development environments as it allows you to quickly and easily create and manage PostgreSQL databases.
Komentar