Interview Prep/Docker/Image design and Dockerfile decisions

What is the difference between `ARG` and `ENV`, and when does each matter?

BeginnerScenarioImage design and Dockerfile decisions
Answer

Situation read → One is build-time, the other persists into the running container.

What I'd do → Use ARG for build parameters (ARG APP_VERSION) and ENV for runtime variables. An ARG declared before FROM is only usable in FROM lines unless redeclared after it. Convert when needed: ENV VERSION=$APP_VERSION.

Why → ARG values appear in docker history and do not exist at runtime; ENV values are visible to anyone with docker inspect.

Interview tip → Neither is a safe place for secrets.

All Docker questions Roadmap: Docker & containers

More on Image design and Dockerfile decisions