DELAPARRA
Index
Color
NL
Category: Docker

ARG

Explained by Updated

What is ARG?

ARG: A build-time variable, passed with --build-arg. Available only during the build, not in the running container. ARG defines a variable that exists only while a Docker image is being built. You pass a value with docker build --build-arg VERSION=1.4, and steps in the Dockerfile can use it. It is handy for choosing a base image version, a package version or a build mode without editing the Dockerfile. Each value becomes part of the image's build history.

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about ARG

What should you keep in mind with ARG?

That is also why ARG is the wrong place for secrets. Values can be read later with docker history, so a password or API token passed this way ends up readable by anyone who has the image. Use Docker's build secrets (RUN --mount=type=secret) instead. And remember that ARG values are gone at runtime. For settings the running container needs, use ENV or, better, environment variables set when the container starts.

What does an example of ARG look like?

ARG VERSION=1.0 RUN echo "building $VERSION"

At a glance

CategoryDocker
Explained by
Updated

More Docker terms

All terms starting with A

Skills

Download all skills (zip)

Manuals

Related services

Need any help?

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.