ARG

The ARG instruction is being used to pass an argument to the Docker daemon during the docker build command. An ARG variable definition comes into effect from the line on which it is defined in the Dockerfile. By using the --build-arg switch, you can assign a value to the defined variable:

$ docker build --build-arg <variable name>=<value> .

The value from the --build-arg will be passed to the daemon building the image. You can specify multiple arguments using multiple ARG instructions. If you specify a build time argument that is not defined using ARG, the build will fail with an error, but the default value can be specified in the Dockerfile . You specify the default argument value this way:

FROM ubuntuARG user=jarek

If no argument will ...

Get Docker and Kubernetes for Java Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.