Your team needs different config per environment. Bake it in the image or inject it?
BeginnerScenarioImage design and Dockerfile decisions
Answer
Situation read → Build once, deploy many.
What I'd do → Keep one image for all environments and inject config at runtime via -e, --env-file, mounted config files, Compose configs, or Kubernetes ConfigMaps/Secrets. Only non-secret defaults go in ENV.
Why → Rebuilding per environment means what you tested is not what you deploy, and secrets could leak into layers.
Interview tip → Twelve-factor: config in the environment.
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.BeginnerProduct asks for a container that runs both nginx and a Python app. What do you say?Beginner