This document explains how to use the Docker Compose file for setting up a PostgreSQL database, ideal for development purposes.
- Docker
- Docker Compose
- Docker Compose Version:
3.8
- Service: PostgreSQL (
db
) - Image:
postgres
-
Start the Database:
- Run
docker-compose up -d
in the directory with thedocker-compose.yml
.
- Run
-
Stop the Database:
- Use
docker-compose down
to stop the service.
- Use
- Ports: Maps host port
5432
to container port5432
. - Environment:
POSTGRES_PASSWORD
:password123
(Change for production)POSTGRES_DB
:cartoon_db
- Volume:
postgres-data
for data persistence at/var/lib/postgresql/data
.