Harden Container Boundaries
- Identify the service function and the minimum runtime permissions it actually needs.
- Use a named non-root UID/GID and verify ownership of every writable path.
- Drop all capabilities, then add back only individually justified capabilities.
- Prevent privilege escalation and prefer a read-only root filesystem with explicit temporary mounts.
- Keep databases and internal services off host ports unless the environment requires a reviewed exception.
- Set resource limits, startup/readiness/liveness checks, and bounded shutdown behavior.
- Use multi-stage builds, pinned dependencies, and granular copies; keep secrets and test tooling out of the final image.
- Validate effective runtime configuration, not only source text.
Do not apply hardening mechanically when it would make required writes or signals impossible. Record each exception, owner, threat, and compensating control.