0
0
Dockerdevops~10 mins

Why multi-stage builds reduce image size in Docker - Test Your Understanding

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

Complete the code to start a multi-stage build with the first stage named 'builder'.

Docker
FROM alpine AS [1]
Drag options to blanks, or click blank then click option'
Abase
Bfinal
Cbuilder
Dstage1
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'final' or 'base' as the first stage name, which is usually reserved for the last stage.
2fill in blank
medium

Complete the code to copy the built binary from the 'builder' stage to the final stage.

Docker
COPY --from=[1] /app/myapp /usr/local/bin/myapp
Drag options to blanks, or click blank then click option'
Astage1
Bfinal
Cbase
Dbuilder
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'final' or 'base' instead of the build stage name.
3fill in blank
hard

Fix the error in the Dockerfile line that copies files from the build stage.

Docker
COPY --from=[1] /app/myapp /usr/local/bin/myapp
Drag options to blanks, or click blank then click option'
Abuild
Bbuilder
Cbuild-stage
Dbuilder-stage
Attempts:
3 left
💡 Hint
Common Mistakes
Using similar but incorrect names like 'build' or 'builder-stage'.
4fill in blank
hard

Fill both blanks to create a final stage that uses a small base image and copies the binary from the builder.

Docker
FROM [1]
COPY --from=[2] /app/myapp /usr/local/bin/myapp
Drag options to blanks, or click blank then click option'
Aalpine
Bbuilder
Cubuntu
Dfinal
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'ubuntu' which is larger, or wrong stage names.
5fill in blank
hard

Fill all three blanks to complete a multi-stage Dockerfile that builds and copies a binary, then sets the entrypoint.

Docker
FROM golang:1.20 AS [1]
WORKDIR /app
COPY . .
RUN go build -o myapp .
FROM [2]
COPY --from=[3] /app/myapp /usr/local/bin/myapp
ENTRYPOINT ["myapp"]
Drag options to blanks, or click blank then click option'
Abuilder
Balpine
Dubuntu
Attempts:
3 left
💡 Hint
Common Mistakes
Using inconsistent stage names or large base images.