All jobs / DevOps / SRE / cloud / Containers
DevOps / SRE / cloud interview question · 1–3 years
The Dockerfile has no USER line, so the app runs as root. Does that matter inside a container?
The strongest answer
Yes — containers share the host kernel, so a breakout or a mounted host path is root on the host; set a non-root USER, read-only root filesystem, drop capabilities and never run privileged
Why it works
Right — container isolation is namespaces and cgroups, not a hypervisor. Least privilege applies inside the box too.
What a good answer covers
- Shared kernel, not a VM.
- USER non-root in the Dockerfile.
- Read-only fs, drop capabilities.
- Never --privileged for an app.
Answers that fall short
- Close, but not the strongest: It matters mostly for compliance; the container isolates root well enough in practice
Isolation is decent but not a boundary you should lean on; the fix costs one line in the Dockerfile. - Weak: No — a container is like a small VM, root inside stays inside
That is the misconception: a container is a process with a restricted view, not a virtual machine. - Red flag: Run it with `--privileged` too, then file permissions never get in the way
Privileged mode removes most of the remaining isolation; an interviewer hears a security red flag.
Who gets asked this
More Containers questions
- The container registry has grown to terabytes, pulls from the cluster are slow, and a public registry started…
- What is the difference between an image and a container?
- A Dockerfile says `FROM node:latest`. What is wrong?
- A container can take all the memory on the node. What do you set?
- In the team’s Docker Compose stack, Postgres loses all its data every time the container is recreated. Why…
- CI rebuilds a 12-minute Docker image on every commit. What do you change first?
- A production image is 1.8 GB and includes a compiler. What do you do?
- The app container connects to `localhost:5432` and gets connection refused, though the database container is…