Skip to content

ARG vs ENV: build-time and run-time variables

Select an icon to see what it is.

Step 5 of 6

Where each value can be read

A container's ENV values appear in docker inspect under Config.Env. A build ARG can be recorded in the image history, so do not count on it staying hidden. Neither one is a safe place for a secret.

$ docker history --no-trunc argdemo

What can be read back

docker inspect argdemo Config.Env: GREETING=hello, APP_VERSION=2.0
docker history argdemo build args can appear in the history, e.g. BUILD_ONLY=demo-value (depends on the builder)
docker run argdemo env has GREETING and APP_VERSION, not BUILD_ONLY