---
source: https://iinventedlight.com/library/notes/docker-arg-and-env.md
title: "Dockerfile ARG is a build-time variable; ENV is set in the image environment"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "Apache-2.0 (Docker docs); Apache-2.0 (docker/docs (GitHub)); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "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)."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-16
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-16
as_of: 2026-11-16
confidence: medium
untested: "Not reproduced (2026-11-16). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-web: Dockerfile ARG and ENV"
tags: [docker, dockerfile, arg, env, build-arg]
client: Librarian
sources:
  - id: S1
    title: "Dockerfile reference (ARG and ENV)"
    publisher: Docker docs
    url: https://docs.docker.com/reference/dockerfile/
    accessed: 2026-11-16
    license: "Apache-2.0"
  - id: S2
    title: "Dockerfile reference (docs source)"
    publisher: docker/docs (GitHub)
    url: https://github.com/docker/docs/blob/main/_vendor/github.com/moby/buildkit/frontend/dockerfile/docs/reference.md
    accessed: 2026-11-16
    license: "Apache-2.0"
---
# 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

- [docker-multi-stage-builds](https://iinventedlight.com/library/notes/docker-multi-stage-builds/)
- [docker-healthcheck](https://iinventedlight.com/library/notes/docker-healthcheck/)
- [docker-build-context](https://iinventedlight.com/library/notes/docker-build-context/)
- [docker-bind-mounts-tmpfs](https://iinventedlight.com/library/notes/docker-bind-mounts-tmpfs/)

## Claims

- id: C1
  claim: The ARG instruction defines a variable users can pass at build time.
  source: S1
  evidence: "instruction defines a variable that users can pass at build time to"

- id: C2
  claim: Pass the value with docker build --build-arg.
  source: S1
  evidence: "--build-arg <varname>=<value>"

- id: C3
  claim: The ENV instruction sets the environment variable key to value.
  source: S2
  evidence: "The `ENV` instruction sets the environment variable `<key>` to the value"

- id: C4
  claim: ARG syntax is ARG <name>[=<default value>].
  source: S2
  evidence: "ARG <name>[=<default value>]"

## Sources

- [S1] Dockerfile reference (ARG and ENV). Docker docs. https://docs.docker.com/reference/dockerfile/ . License: Apache-2.0. Accessed 2026-11-16.

- [S2] Dockerfile reference (docs source). docker/docs (GitHub). https://github.com/docker/docs/blob/main/_vendor/github.com/moby/buildkit/frontend/dockerfile/docs/reference.md . License: Apache-2.0. Accessed 2026-11-16.

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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
