Interview Prep/Docker/Rapid-Fire Commands

What is your go-to sequence to harden and verify a container before shipping?

AdvancedProductionRapid-Fire Commands
Answer
hadolint Dockerfile
docker build -t app:test .
trivy image --exit-code 1 --severity HIGH,CRITICAL app:test
docker run -d --name t --read-only --tmpfs /tmp --cap-drop ALL \
  --security-opt no-new-privileges --user 10001 --pids-limit 200 --memory 512m -p 8080:8080 app:test
sleep 5; curl -fsS localhost:8080/healthz; docker inspect -f '{{.State.Status}} {{.State.OOMKilled}}' t
docker rm -f t

If it runs healthy under those constraints, it will run under any sane production policy.

All Docker questions Roadmap: Docker & containers

More on Rapid-Fire Commands