Creating Docker Compose for PostgreSQL Server
Create the Docker Compose file
The first step consists of creating the configuration file to run our containers. A Docker Compose file is a YAML file that defines the services that make up an application. In our case, we will define a PostgreSQL service and a pgAdmin service.
PgAdmin
PgAdmin can be deployed in a container using the image at https://hub.docker.com/r/dpage/pgadmin4.
PostgreSQL
For PostgreSQL, we will use the official image at https://hub.docker.com/_/postgres.
Example docker-compose.yml file for PgAdmin and PostgreSQL
```yaml version: '3.7' services: postgres: image: 'postgres:latest' container_name: 'pg_container' ports: - '5432:5432' environment: - POSTGRES_PASSWORD=mypassword pgadmin: image: 'dpage/pgadmin4' container_name: 'pgadmin_container' ports: - '8000:80' environment: - PGADMIN_DEFAULT_EMAIL=myemail@example.com - PGADMIN_DEFAULT_PASSWORD=mypassword ```Conclusion
In this article, we have seen how to set up PostgreSQL and pgAdmin using Docker Compose. This is a simple and portable way to run and manage PostgreSQL databases.
Komentar