Harden the runtime and secret boundary
Worked example
This is an offline lesson. Data are fictional and Docker commands are unexecuted. Any optional execution requires an authorized disposable VM, a verified context, synthetic data, restricted access and no external transmission. Do not collect secrets or private output. Before any separately authorized Docker query, verify the effective endpoint and builder (including environment overrides), not just the context name. Use only disposable lab resources; a failed check is a stop condition, not permission to retry against a different host.
Expected controls (not observed runtime):user: 10001:10001; read_only: true; cap_drop: [ALL]security_opt: [no-new-privileges:true]; mem_limit: 128mcpus: 0.5; pids_limit: 64; bounded local log rotationAPI volume /data read-write; proxy has no data volume.Secret file readable by API user, never baked into the image.Proxy allows GET only; backend token is synthetic.Nonroot reduces the process privileges but is distinct from a rootless daemon. A read-only root filesystem still allows explicitly writable mounts. Check the actual effective user, capabilities, mount access and limits in the target runtime. SQLite needs write permission to its database directory for journal files. Compose file-based secrets are mounted files, and their ownership/mode may reflect host implementation; do not rely on uid/gid overrides for file sources. This lab generates a non-sensitive fixture readable by the numeric user, and the proxy is not granted the file. Real secrets require approved injection, permission handling, rotation and transport security. The lab has no TLS and must stay isolated. Structured logs contain method, fixed route label and status, not token, query or request body. The file-backed local Compose secret is bind-mounted; numeric container UID does not guarantee readability. The fixture file is deliberately non-sensitive and readable; never copy its mode into real secret handling. Check effective user, capabilities, mount access and limits, including a positive API access control and negative proxy test without revealing contents.
Common mistake
Do not fix a permission error with privileged mode or chmod 777. Diagnose the exact file or mount and preserve least privilege.
Manual practice
Review the Compose controls and identify which require runtime evidence. Explain why the proxy must not receive the write token or a data mount.
Worksheet: lab-fixtures/docker-professional-capstone/05-hardening/scenario.txt. Project: lab-fixtures/docker-professional-capstone/project/.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Harden the runtime and secret boundary — Knowledge check
Interpret capstone evidence and make a safe operational decision.
Does read_only prohibit writes to a separate writable volume?
Who receives the synthetic write token?
Does nonroot USER mean the daemon is rootless?