0
0
Dockerdevops~10 mins

ARG and ENV instructions in Docker - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the Dockerfile line to declare a build-time variable named VERSION.

Docker
ARG [1]
Drag options to blanks, or click blank then click option'
AVERSION
BENV
CRUN
DCOPY
Attempts:
3 left
💡 Hint
Common Mistakes
Using ENV instead of ARG for build-time variables
Using RUN or COPY which are unrelated here
2fill in blank
medium

Complete the Dockerfile line to set an environment variable named PATH inside the container.

Docker
ENV [1]=/usr/local/bin
Drag options to blanks, or click blank then click option'
AHOME
BPATH
CVERSION
DUSER
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing ARG and ENV variables
Using unrelated variable names like HOME or USER
3fill in blank
hard

Fix the error in this Dockerfile line that tries to use a build argument inside ENV.

Docker
ENV APP_VERSION=[1]
Drag options to blanks, or click blank then click option'
A$APP_VERSION
BAPP_VERSION
C${APP_VERSION}
DARG_APP_VERSION
Attempts:
3 left
💡 Hint
Common Mistakes
Using $APP_VERSION without braces
Using the literal variable name without expansion
4fill in blank
hard

Fill both blanks to declare a build argument and set it as an environment variable with a default value.

Docker
ARG [1]=1.0
ENV [2]=$[1]
Drag options to blanks, or click blank then click option'
AAPP_VERSION
BVERSION
Attempts:
3 left
💡 Hint
Common Mistakes
Using different names for ARG and ENV
Forgetting the default value in ARG
5fill in blank
hard

Fill all three blanks to create a Dockerfile snippet that declares a build argument, sets an environment variable, and uses it in a RUN command.

Docker
ARG [1]=latest
ENV [2]=$[1]
RUN echo "Version is [3]"
Drag options to blanks, or click blank then click option'
AAPP_TAG
C$APP_TAG
Attempts:
3 left
💡 Hint
Common Mistakes
Using different names for ARG and ENV
Not using $ to reference variables in RUN