What is the scope of a variable defined using the ARG instruction within a Dockerfile?
Experience Level: Senior
Tags: Docker
Answer
An ARG variable definition comes into effect from the line on which it is defined in the Dockerfile not from the argument’s use on the command-line or elsewhere.
Related Docker job interview questions
Are ARG variables persisted into the built images in Docker?
Docker SeniorYou have a variable declared using ARG and the same variable declared using ENV instruction in your Dockerfile. What variable value will be used?
Docker SeniorHow do you provide default values for variables defined using ARG instruction in Dockerfile?
Docker SeniorWhat is the ARG instruction good for in Docker?
Docker SeniorDoes FROM instruction support variables within a Dockerfile?
Docker Senior