Sats Coop catalog

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