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.
More on Security and scanning
A scan reports 300 CVEs in your base image. How do you triage?IntermediateAdd vulnerability scanning to CI so critical findings block the merge.BeginnerWhy is mounting `/var/run/docker.sock` into a container dangerous?IntermediateA developer asks for `--privileged`. What do you do?IntermediateA pentester got root inside a container. How bad is it?AdvancedChoose a base image strategy for security across the company.Advanced