Docker Compose security hardening
Ten mistakes that turn up in self-hosted compose files, and the fix for each.
Free excerpt
Databases published to the world
ports: - "5432:5432" binds on all interfaces. Remove it, or use 127.0.0.1:5432:5432; let containers talk over an internal network.
Docker bypasses ufw
Published ports are opened through Docker's own iptables rules. Restrict them in the DOCKER-USER chain, then verify from another machine.
Mounting docker.sock
/var/run/docker.sock in a container is root on the host. Avoid it or use a socket proxy with a narrow allow-list.
Running as root with all capabilities
Set user: "10001:10001", cap_drop: [ALL] and add back only what is needed.
No no-new-privileges, writable root filesystem
security_opt: [no-new-privileges:true], read_only: true and a small tmpfs for /tmp.
Secrets in environment variables and git
Use compose secrets: (files with mode 600) and *_FILE variables; keep them out of git.
Floating tags
latest changes under you. Pin a version tag plus the digest.
One flat network
Split networks: edge, backend and an internal: true data network with no outbound route.
No resource limits
mem_limit, cpus and pids_limit stop one container from taking down the host.
Unbounded logs, no healthchecks
Set json-file with max-size/max-file and add healthchecks so depends_on can wait for readiness.
The paid pack includes the PDF checklist, a hardened compose.yaml, daemon.json, a DOCKER-USER firewall script and compose-audit.py to scan running containers.
Get the full pack
Sats Werkstatt
Docker Compose Security Hardening Checklist + Audit ScriptHarden self-hosted Docker stacks: cap_drop, read_only, secrets, networks, ufw bypass, backups. PDF checklist + hardened compose.yaml, daemon.json, DOCKER-USER firewall script and compose-audit.py to scan running containers. Tested script. EN.
9,000 sats English
Buy with Lightning
Docker Compose Güvenlik Sıkılaştırma Listesi + BetikSelf-host Docker yığınlarını sıkılaştırın: cap_drop, read_only, gizli bilgiler, ağlar, ufw atlatması, yedekler. PDF kontrol listesi + sıkılaştırılmış compose.yaml, daemon.json, DOCKER-USER betiği ve çalışan konteynerleri tarayan compose-audit.py. Türkçe.
4,500 sats Türkçe
Buy with Lightning
Docker Compose Security Checklist + Audit Script (Tagalog)I-secure ang self-hosted Docker stacks: cap_drop, read_only, secrets, networks, ufw bypass, backups. PDF checklist sa Tagalog + hardened compose.yaml, daemon.json, DOCKER-USER firewall script at compose-audit.py na nag-i-scan ng tumatakbong containers.
3,500 sats Filipino (Tagalog)
Buy with Lightning