Threat modeling for Docker containers
A threat model identifies what needs protection, who or what can harm it, and which boundaries a request crosses. A Linux container shares the kernel of its Linux host (which may be a VM). Isolation is valuable, but does not make arbitrary untrusted code safe. Start with a fictional receipt service that reads an order and prints a total.
Worked example
This is an offline lesson. Scenarios are fictional and Docker commands are unexecuted. Any optional execution requires an approved disposable VM, a reviewed preloaded image with verified digest, blocked external access and appropriate resource limits. No host-policy change, real credentials or live scan is required. Keep the exercise offline. Before any separately authorized runtime check, verify the effective daemon, builder, runner or deployment identity as applicable; use synthetic data, reviewed inputs and bounded resources. Record missing evidence as NOT RUN.
Assets: order data, host files, image identity, service availabilityBoundaries: registry -> builder -> image -> runtime -> host kernelNeed: read synthetic input; write result to stdoutNot needed: host control, public ports, persistent credentialsResidual risk: application bugs, kernel bugs, resource exhaustionFor each boundary ask what is allowed, what must be denied, and what evidence would demonstrate the difference. Use only a reviewed image, narrow inputs, no host mounts, no external network for this offline job, and bounded resources. A service that genuinely needs a database would instead need a scoped network and database identity. Test the intended output and verify denied access in a separately authorized lab. A container boundary, application authentication and kernel controls address different risks. Resource limits address availability, not access to confidential records. Keep host and dependencies patched and use stronger isolation for hostile workloads. For each proposed control define an allowed behavior, an expected denied behavior, and the evidence needed to distinguish a policy denial from an unrelated failure. A checklist is not enforcement; the toy hardening commands later in this chapter do not include every resource limit in the checklist.
Common mistake
A running container is not proof of isolation. Record which controls are enforced and which are only planned.
Manual practice
For a report generator that only reads a synthetic CSV, identify three assets, two unnecessary permissions, a positive test and a negative test. Explain one remaining risk.
Worksheet: lab-fixtures/docker-container-security/01-threat-model/scenario.txt.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Threat modeling for Docker containers — Knowledge check
Apply defensive container security reasoning in a fictional scenario.
Why is ordinary container isolation insufficient for hostile code?
Which control mainly addresses excessive memory consumption?
What evidence should a threat model request?