0
0
Dockerdevops~10 mins

Squashing layers 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 command to squash layers during build.

Docker
docker build [1] .
Drag options to blanks, or click blank then click option'
A--tag
B--rm
C--squash
D--pull
Attempts:
3 left
💡 Hint
Common Mistakes
Using --tag instead of --squash
Forgetting to add the --squash option
Using --rm which removes intermediate containers but does not squash layers
2fill in blank
medium

Complete the Docker build command to tag the image while squashing layers.

Docker
docker build [1] myimage:latest --squash .
Drag options to blanks, or click blank then click option'
A--tag
B--rm
C--quiet
D--pull
Attempts:
3 left
💡 Hint
Common Mistakes
Using --pull which updates base images but does not tag
Using --rm which removes intermediate containers
Using --quiet which suppresses output
3fill in blank
hard

Fix the error in this Dockerfile line to squash layers by combining RUN commands.

Docker
RUN apt-get update && apt-get install -y curl && [1]
Drag options to blanks, or click blank then click option'
Aapt-get clean
Bapt-get remove
Capt-get upgrade
Dapt-get autoremove
Attempts:
3 left
💡 Hint
Common Mistakes
Using apt-get remove which deletes packages
Using apt-get upgrade which updates packages but does not clean
Using apt-get autoremove which removes unused packages but not cache
4fill in blank
hard

Fill both blanks to create a squashed image by combining commands in one RUN statement.

Docker
RUN [1] && [2] && rm -rf /var/lib/apt/lists/*
Drag options to blanks, or click blank then click option'
Aapt-get update
Bapt-get install -y git
Capt-get clean
Dapt-get upgrade
Attempts:
3 left
💡 Hint
Common Mistakes
Using apt-get clean before install
Using apt-get upgrade instead of install
Not chaining commands properly
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that filters and transforms Docker image tags.

Docker
tags = {tag[1]:tag[2] for tag in images if tag[3] 'latest'}
Drag options to blanks, or click blank then click option'
A.split('-')[0]
B.upper()
C!=
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using '==' instead of '!=' in the filter
Not splitting the tag for the key
Not converting tag to uppercase