ARG

The Dockerfile instruction that declares a variable you can set at build time with --build-arg.

Values can be read back from image history, so they must never hold secrets.

In more detail

ARG values exist only while building, not in the running container, though they can appear in image history. Never pass secrets through ARG; use a build secret instead. An ARG declared before FROM can choose the base image version.

Example

ARG PYTHON_VERSION=3.12
FROM python:${PYTHON_VERSION}-alpine

Related terms

Taught in

References

Certification courses