After enabling `readOnlyRootFilesystem: true`, the app crashes writing to `/tmp`. How do you proceed?
IntermediateScenarioContainer and IaC Security
Answer
Situation read → Read-only root is a good control; the app just needs explicit writable paths.
What I'd do →
- Find the writes:
kubectl logsshowsRead-only file systemerrors with the path. - Mount
emptyDirat the needed paths:
volumeMounts:
- name: tmp
mountPath: /tmp
volumes:
- name: tmp
emptyDir: {}
- Redirect caches and logs to stdout or those mounts.
- Keep
readOnlyRootFilesystem: true.
Why → An attacker cannot drop binaries into the image filesystem.
Interview tip → Do not remove the control to fix the symptom.
More on Container and IaC Security
A team asks whether to use `ubuntu`, `alpine` or a distroless base image. How do you advise?Beginner`trivy image` shows 300 vulnerabilities in your app image. How do you bring this down?BeginnerA Dockerfile runs the app as root. How do you fix it and prove the fix?IntermediateCheckov fails a Terraform PR because an S3 bucket allows public access. What do you change?BeginnerHow do you set up image scanning so nothing vulnerable reaches production?IntermediateAn image passed scanning three weeks ago and runs in production. A new critical CVE is published today. What happens next?Intermediate