PostgreSQL with Docker Compose
PostgreSQL with a health check, reachable from the host only. The services are ticked below: set your project name and port, then copy compose.yaml and .env.
- Free
- No Sign-Up
- Runs in Your Browser
Services
NoteReplace every change-me in .env with a long random password (openssl rand -base64 24) before the first start: databases keep the first password they are given.
NoteDatabase ports are bound to 127.0.0.1, so only this server can reach them. Never publish them on all addresses: Docker's ports bypass UFW.
compose.yaml
# compose.yaml, generated at frabs.net/tools/docker-compose-generator/
services:
postgres:
image: postgres:17-alpine
restart: unless-stopped
ports:
- "127.0.0.1:5432:5432"
environment:
POSTGRES_DB: app
POSTGRES_USER: app
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
volumes:
- postgres:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U app -d app"]
interval: 10s
retries: 5
volumes:
postgres:
.env
# .env (keep out of version control) POSTGRES_PASSWORD=change-me
Start It
docker compose up -d && docker compose ps
Docker Compose Generator
What you get
Servicespostgres
ImagesPinned to a major version
DataNamed volumes
Secrets.env file
DatabasesNot published to the internet
PostgreSQL with a health check, reachable from the host only.
Start it with docker compose up -d; update later with docker compose pull && docker compose up -d.
Questions
How do I run PostgreSQL with Docker Compose?
Save compose.yaml and .env in an empty folder, set real passwords in .env, then run docker compose up -d.
Free Tools
More tools
Docker Compose GeneratorStarter compose.yaml files for common stacks, with safe defaults.Nginx Config GeneratorServer blocks for reverse proxies, static sites and PHP, with HTTPS.VPS RAM CalculatorHow much memory a server needs for its OS, apps, databases and caches.Linux Command GeneratorReady-to-run commands for disks, networking, services, logs and diagnostics.
Run VMs for other people?
Frabs stops spam, scans and floods leaving your customers' VMs, before the abuse report lands.