The ARG directive in a Dockerfile is used to define variables that users can pass at build time to the builder with the docker build command.
These variables behave similarly to environment variables and can be used throughout the Dockerfile but are not persisted in the final image unless explicitly declared using the ENV directive.
The ARG directive has the following format:
ARG <varname>
We can also add multiple ARG directives, as follows:
ARG USER
ARG VERSION
These arguments can also have optional default values specified within the Dockerfile itself.
If no value is provided by the user during the build process, Docker uses the default value defined in the ARG instruction:
ARG USER=TestUser
ARG VERSION=1.0.0
Unlike the ENV variables, ARG variables are not accessible from the running container. They are only available during the build process.
