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.
More on Write-a-Dockerfile tasks
Write a production Dockerfile for a Node.js API using a multi-stage build.IntermediateWrite a Dockerfile for a Python Flask app that runs with gunicorn as a non-root user.BeginnerWrite a Dockerfile for a Go service that produces a tiny image (under 20 MB).IntermediateWrite a multi-stage Dockerfile for a Java Spring Boot app built with Maven.IntermediateWrite a Dockerfile for a static React site served by Nginx.BeginnerThis Dockerfile rebuilds dependencies on every code change. Fix it.Beginner