Interview Prep/Real-World Interview/Write-a-Dockerfile tasks

Write the `docker run` command that runs a container with hardened runtime settings.

AdvancedHands-onWrite-a-Dockerfile tasks
Answer
docker run -d --name api \
  --read-only --tmpfs /tmp:rw,size=64m \
  --cap-drop ALL --cap-add NET_BIND_SERVICE \
  --security-opt no-new-privileges:true \
  --user 10001:10001 \
  --memory 512m --cpus 1 --pids-limit 200 \
  -p 8080:8080 myapp:1.4.2

Key trick → A read-only root filesystem plus dropping all capabilities blocks most post-exploit actions. --pids-limit stops fork bombs, and no-new-privileges blocks setuid escalation.

All Real-World Interview questions Roadmap: Interview readiness

More on Write-a-Dockerfile tasks