Product asks for a container that runs both nginx and a Python app. What do you say?
BeginnerScenarioImage design and Dockerfile decisions
Answer
Situation read → One-process-per-container is a guideline, not a law, but mixing hurts signal handling, scaling and logs.
What I'd do →
- Propose two containers (nginx + app) in one Compose file or one Pod.
- Share traffic via a user-defined network, or a Unix socket on a shared volume.
- If truly required, use a minimal init such as
tiniors6-overlayto supervise both.
Why → Independent restarts, independent scaling, clean docker logs per concern.
Interview tip → Acknowledge the exception (sidecars/supervised legacy apps) rather than being dogmatic.
More on Image design and Dockerfile decisions
A teammate's Node.js image is 1.2 GB. How do you approach shrinking it?BeginnerYou need to run `apt-get install` in a Dockerfile. How do you write it so the layer stays small and cache-safe?BeginnerWhen would you pick `COPY` over `ADD`?BeginnerA service must run a startup script and then the app. Should you use `CMD`, `ENTRYPOINT`, or both?BeginnerYour Docker build re-installs all Python dependencies on every code change. Fix it.BeginnerYour app ignores `docker stop` and takes exactly 10 seconds to die. Why and what do you change?Intermediate