Docker compose configuration for Postgresql and PGadmin
Monday, May 19, 2025For my next side project I will use FastAPI and Postgresql on the backend, so I would like to share this simple docker-compose.yml
file with you which starts up a Postgresql instance with PGadmin for management.
Simple and very useful!
version: "3.8"
services:
postgres:
container_name: postgres_db
image: postgres:latest
restart: always
ports:
- "5432:5432"
environment:
POSTGRES_USER: root
POSTGRES_PASSWORD: root
POSTGRES_DB: mydatabase
volumes:
- ./data:/var/lib/postgresql/data
pgadmin:
image: dpage/pgadmin4
restart: always
ports:
- "8080:80"
environment:
PGADMIN_DEFAULT_EMAIL: admin@example.com
PGADMIN_DEFAULT_PASSWORD: admin
depends_on:
- postgres