Interview Prep/Docker/Image design and Dockerfile decisions

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.

All Docker questions Roadmap: Docker & containers

More on Image design and Dockerfile decisions