Register to Better Coder! It's free.
Enjoy the premium features and succeed at every job interview.

How do you provide default values for variables defined using ARG instruction in Dockerfile?

Experience Level: Senior
Tags: Docker

Answer

An ARG instruction can optionally include a default value like this:

FROM busybox
ARG user1=someuser
ARG buildno=1
# ...

If an ARG instruction has a default value and if there is no value passed at build-time, the builder uses the default.

Comments

No Comments Yet.
Be the first to tell us what you think.
Docker instructions
Docker instructions

Are you learning Docker ? Try our test we designed to help you progress faster.

Test yourself