0
0
Dockerdevops~10 mins

Image layers concept in Docker - Interactive Code Practice

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

Complete the code to build a Docker image from a Dockerfile.

Docker
docker build -t myapp [1] Dockerfile .
Drag options to blanks, or click blank then click option'
A-d
B-f
C--rm
D--push
Attempts:
3 left
💡 Hint
Common Mistakes
Using -d which is for detached mode in run command
Using --push which is for pushing images
Using --rm which removes intermediate containers
2fill in blank
medium

Complete the Dockerfile line to add a new file to the image.

Docker
COPY [1] /app/
Drag options to blanks, or click blank then click option'
Afile.txt
B./app/file.txt
C/app/file.txt
D/file.txt
Attempts:
3 left
💡 Hint
Common Mistakes
Using absolute paths which are not in the build context
Adding destination path in the source position
3fill in blank
hard

Fix the error in the Dockerfile line that sets the working directory.

Docker
WORKDIR [1]app
Drag options to blanks, or click blank then click option'
A/
B./
C/home/
Attempts:
3 left
💡 Hint
Common Mistakes
Using relative paths like 'app' or './app'
Missing the leading slash for absolute path
4fill in blank
hard

Fill both blanks to create a Dockerfile line that runs a command and creates a new image layer.

Docker
RUN [1] && [2]
Drag options to blanks, or click blank then click option'
Aapt-get update
Bapt-get install -y curl
Cecho 'Hello World'
Drm -rf /var/lib/apt/lists/*
Attempts:
3 left
💡 Hint
Common Mistakes
Running install before update
Using echo which does not install software
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps image layers to their sizes if size is greater than zero.

Docker
layer_sizes = { [1]: [2] for [3], size in layers.items() if size > 0 }
Drag options to blanks, or click blank then click option'
Alayer
Bsize
Dlayer.upper()
Attempts:
3 left
💡 Hint
Common Mistakes
Using layer instead of layer.upper() for keys
Mixing up keys and values in comprehension