0
0
Dockerdevops~10 mins

Reducing image size strategies 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 use a minimal base image.

Docker
FROM [1]
Drag options to blanks, or click blank then click option'
Acentos:latest
Bubuntu:latest
Calpine:latest
Ddebian:latest
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing a full OS base image like ubuntu increases image size.
2fill in blank
medium

Complete the command to remove unnecessary package lists after installation to reduce image size.

Docker
RUN apk add --no-cache curl && rm -rf [1]
Drag options to blanks, or click blank then click option'
A/var/cache/apk/*
B/usr/local/bin/*
C/tmp/*
D/etc/apk/*
Attempts:
3 left
💡 Hint
Common Mistakes
Removing wrong directories that don't reduce image size.
3fill in blank
hard

Fix the error in the Dockerfile line to combine commands and reduce image layers.

Docker
RUN apt-get update && apt-get install -y curl [1] apt-get clean
Drag options to blanks, or click blank then click option'
A||
B;
C|
D&&
Attempts:
3 left
💡 Hint
Common Mistakes
Using ';' continues even if previous commands fail.
4fill in blank
hard

Fill both blanks to create a multi-stage build that copies only the final binary.

Docker
FROM golang:1.20 AS builder
RUN go build -o app .
FROM [1]
COPY --from=builder [2] /app
Drag options to blanks, or click blank then click option'
Aalpine:latest
B/app
C/app/app
Dubuntu:latest
Attempts:
3 left
💡 Hint
Common Mistakes
Using a large base image in the final stage increases size.
5fill in blank
hard

Fill all three blanks to create a Dockerfile snippet that cleans cache and removes build dependencies.

Docker
RUN apt-get update && apt-get install -y build-essential curl && \
    make build && \
    apt-get purge -y [1] && \
    rm -rf [2] && \
    apt-get autoremove -y && \
    rm -rf [3]
Drag options to blanks, or click blank then click option'
Abuild-essential
B/var/lib/apt/lists/*
C/tmp/*
Dcurl
Attempts:
3 left
💡 Hint
Common Mistakes
Not removing build dependencies or cache increases image size.