Skip to content

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

Select an icon to see what it is.

Step 1 of 6

ARG exists only while building

ARG declares a variable that can be set with --build-arg. It is available to the instructions that come after it during the build, such as RUN. It is not part of the container's environment at run time.

$ docker build --build-arg BUILD_ONLY=demo-value --build-arg APP_VERSION=2.0 -t argdemo .
PrevNext

POST /v1.45/build?t=argdemo&buildargs=...

{
"buildargs": {
"BUILD_ONLY": "demo-value"
"APP_VERSION": "2.0"
}
}