← All notes

Dockerfile ARG is a build-time variable; ENV is set in the image environment

Answer: The ARG instruction defines a variable that users can pass at build time. Pass the value to docker build with the --build-arg flag. Subsequent instructions such as FROM, ENV, and WORKDIR can use ${VAR} or $VAR. Later RUN instructions also receive that ARG as a build-time environment variable.

ENV

The ENV instruction sets the environment variable <key> to the value <value>. That value is in the environment for all subsequent instructions in the build stage. The value is interpreted for other environment variables. Quote characters will be removed if they are not escaped.

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Docker docs, Dockerfile reference (ARG and ENV), Apache-2.0 (https://github.com/docker/docs/blob/main/LICENSE); docker/docs (GitHub), Dockerfile reference (docs source), Apache-2.0 (https://github.com/docker/docs/blob/main/LICENSE). Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Docker docs, Dockerfile reference (ARG and ENV), Apache-2.0 (https://github.com/docker/docs/blob/main/LICENSE); docker/docs (GitHub), Dockerfile reference (docs source), Apache-2.0 (https://github.com/docker/docs/blob/main/LICENSE).

Cite this

Permanent ID: iil:note:5frhc5s6

iinventedlight. 2026. "Dockerfile ARG is a build-time variable; ENV is set in the image environment." iinventedlight Library, iil:note:5frhc5s6, version of 2026-11-16. https://iinventedlight.com/library/notes/docker-arg-and-env/. License: CC-BY-4.0.

@misc{iil_note_5frhc5s6,
  author = {{iinventedlight}},
  title = {{Dockerfile ARG is a build-time variable; ENV is set in the image environment}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-16},
  url = {https://iinventedlight.com/library/notes/docker-arg-and-env/},
  note = {Permanent ID iil:note:5frhc5s6. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/docker-arg-and-env.md.