Interview Prep/Docker/Security and scanning

Harden a container run command for a stateless web API.

IntermediateScenarioSecurity and scanning
Answer

Situation read → Apply defense in depth.

What I'd do →

docker run -d --name api \
  --read-only --tmpfs /tmp \
  --cap-drop ALL \
  --security-opt no-new-privileges:true \
  --pids-limit 200 --memory 512m --cpus 1 \
  --user 10001:10001 \
  -p 127.0.0.1:8080:8080 myapi:1.8.2

Why → Each flag removes a class of post-exploitation action.

Interview tip → Mention keeping the default seccomp profile on and not disabling it.

All Docker questions Roadmap: Docker & containers

More on Security and scanning