Container security checklist for self-hosters
A practical security checklist for self-hosted Docker apps: updates, digest pinning, signed sources, minimal exposure, the Docker socket, secrets and backups.
Self-hosted servers rarely get hacked through clever zero-days. They get hacked through an admin panel left open with a default password, an app two years behind on updates, a database port published to the internet, or a compose file copied from a forum. This checklist covers the practical steps that close those doors, in rough order of value.
1. Keep things updated
- The host: enable unattended security upgrades on Ubuntu and reboot when the kernel asks.
- Docker Engine itself, through the distribution’s or Docker’s repository.
- Each app: watch its releases, and update deliberately (see the next point) rather than never.
sudo apt install unattended-upgrades
sudo dpkg-reconfigure -plow unattended-upgrades
[ -f /var/run/reboot-required ] && echo "reboot needed"2. Pin images by digest, and know your sources
A tag such as latest, or even 16, can be moved by whoever controls the image. Pinning to a digest (image: app:1.4.2@sha256:…) means you run exactly the bytes you reviewed, and updates happen when you choose. Prefer official images or the project’s own registry over a random re-upload. Where projects sign their images (for example with Sigstore cosign), verify the signature in your pipeline.
3. Expose as little as possible
- Only ports 80 and 443 (and SSH) should face the internet. Put every web app behind one reverse proxy.
- Never publish database, cache or admin ports (5432, 6379, 9000…) to 0.0.0.0. If a container port must be published for local tools, bind it to 127.0.0.1.
- Know that ports Docker publishes are opened through its own iptables rules and are not filtered by UFW in the default setup. Check from outside with nmap rather than trusting your firewall config.
- Admin interfaces that only you use belong behind a VPN or an IP allowlist, not on the open internet.
# from another machine
nmap -Pn -p- your.server.ip4. Treat the Docker socket as root
Anything that can talk to /var/run/docker.sock can start a privileged container and take over the host. Mount it into a container only when there is no alternative, prefer a socket proxy that allows read-only calls, and do not add everyday users to the docker group lightly — membership is effectively root.
5. Read compose files before running them
Look specifically for privileged: true, network_mode: host, cap_add, pid: host, devices, and volumes that mount / or /etc or the Docker socket. Each one may be legitimate for a particular tool, but each one weakens the wall between the container and your server. Run containers as a non-root user when the image supports it, and add read_only: true where the app allows.
6. Handle secrets properly
- Keep secrets in an .env file with chmod 600, outside git, or use Docker secrets in Swarm.
- Change every default password on first login. Turn on two-factor authentication wherever the app supports it.
- Remember that environment variables are visible to anyone who can run docker inspect.
7. Harden SSH
# /etc/ssh/sshd_config.d/hardening.conf
PasswordAuthentication no
PermitRootLogin prohibit-passwordUse keys, disable password logins, and consider fail2ban or a VPN-only SSH if your logs show constant brute-force attempts.
Limit what a container can do
A few compose options shrink the damage if an app is compromised. They are cheap to add, and an app that breaks with them tells you something about it:
services:
app:
image: example/app:1.4.2@sha256:<digest>
user: "1000:1000"
read_only: true
tmpfs: [ /tmp ]
cap_drop: [ ALL ]
security_opt: [ "no-new-privileges:true" ]
mem_limit: 512m
pids_limit: 200user runs the process as a non-root ID; read_only stops it writing outside its volumes; cap_drop removes kernel capabilities it should not need; no-new-privileges blocks setuid tricks; the memory and process limits stop one runaway app from taking down every other app on the server. Add capabilities back one at a time only when an app proves it needs them.
8. Backups are a security control
Ransomware and destructive mistakes are answered by backups, not firewalls. Keep an encrypted copy off the server, ideally one that the server itself cannot delete, and test restoring it.
What Keenrig does for you
- Signed, pinned catalog: every app manifest pins an exact image digest, and the whole catalog is Ed25519-signed and verified with a key built into the binary before any entry is trusted.
- Minimal exposure: app containers are not published on host ports; the Caddy gateway reaches them over Docker’s internal network, so only 80 and 443 face the internet.
- HTTPS for every app domain, obtained and renewed automatically.
- Accounts: admin accounts live on your server, with two-factor authentication through an authenticator app and role-based access control.
- Encrypted backups: snapshots are always encrypted with a passphrase you choose, and can be restored onto a blank server.
- Platform updates: with automatic upgrades on (the default), the server checks every 5 minutes for a new Keenrig release, health-checks the upgrade and rolls back if it fails.
curl -fsSL https://get.keenrig.com | sudo shWhat Keenrig does not do (yet)
- No web application firewall. The default gateway is Caddy without WAF modules, and an nginx gateway with ModSecurity is not available yet.
- Keenrig release files are checked by SHA-256 checksum, not yet by signature; the catalog is signed, the platform binaries are not.
- It does not configure the host for you: unattended OS upgrades, SSH hardening and host firewall rules are still yours.
- It does not scan app images for vulnerabilities, and it does not send security alerts.
- The admin panel on the server’s IP uses a self-signed certificate until you give it a domain; set a domain, or reach it over a VPN.