What is the ARG instruction good for in Docker?
Experience Level: Senior
Tags: Docker
Answer
The ARG instruction defines a variable that users can pass at build-time to the builder with the docker build command using the --build-arg <varname>=<value> flag. If a user specifies a build argument that was not defined in the Dockerfile, the build outputs a warning.
A Dockerfile may include one or more ARG instructions. For example, the following is a valid Dockerfile:
FROM busybox
ARG user1
ARG buildno
# ...
Related Docker job interview questions
What is the scope of a variable defined using the ARG instruction within a Dockerfile?
Docker SeniorHow do you provide default values for variables defined using ARG instruction in Dockerfile?
Docker SeniorDoes FROM instruction support variables within a Dockerfile?
Docker SeniorHow many times can the FROM instruction appear within a Dockerfile?
Docker SeniorWhat is the FROM instruction good for in Docker?
Docker Senior