version: "3.7"
services:
postgres:
container_name: postgres
image: postgres:latest
restart: always
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
logging:
options:
max-size: 10m
max-file: "3"
ports:
- "5432:5432"
volumes:
- ./data/postgres-data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready"]
interval: 10s
timeout: 5s
retries: 5
pgadmin:
container_name: pgadmin
image: dpage/pgadmin4
restart: always
environment:
PGADMIN_DEFAULT_EMAIL: [email protected]
PGADMIN_DEFAULT_PASSWORD: root
ports:
- "5050:80"
volumes:
- ./data/pgadmin-data:/var/lib/pgadmin
- Insert this code inside a docker-compose.yml file.
- Run the following command inside the directory of the file :
docker compose up -d
- Your database is running on port 5432 binded on your localhost
- Connect to your PG-Admin instance on : http://localhost:5050
- Enter the following credentials :
- Connect to the PG instance :
- Add new Server —> Connection pannel
- Add : postgres as host
- Add : postgres as user
- Add : postgres as password