You have a variable declared using ARG and the same variable declared using ENV instruction in your Dockerfile. What variable value will be used?
Experience Level: Senior
Tags: Docker
Answer
You can use an ARG or an ENV instruction to specify variables that are available to the RUN instruction. Environment variables defined using the ENV instruction always override an ARG instruction of the same name.
Related Docker job interview questions
What is the RUN instruction good for in Docker?
Docker SeniorAre ARG variables persisted into the built images in Docker?
Docker SeniorWhat 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 SeniorWhat is the ARG instruction good for in Docker?
Docker Senior