0
0
Dockerdevops~10 mins

Why image optimization matters in Docker - Test Your Understanding

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

Complete the Dockerfile line to set the base image to Alpine Linux, which is small and efficient.

Docker
FROM [1]
Drag options to blanks, or click blank then click option'
Aalpine:latest
Bubuntu:latest
Cdebian:latest
Dcentos:latest
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing a larger base image like ubuntu increases image size unnecessarily.
2fill in blank
medium

Complete the Dockerfile command to remove package cache after installing packages to reduce image size.

Docker
RUN apk add --no-cache curl && [1]
Drag options to blanks, or click blank then click option'
Aapt-get clean
Brm -rf /var/lib/apt/lists/*
Crm -rf /var/cache/apk/*
Dyum clean all
Attempts:
3 left
💡 Hint
Common Mistakes
Using commands for other package managers like apt or yum.
3fill in blank
hard

Fix the error in the Dockerfile line to copy only necessary files to keep the image small.

Docker
COPY [1] /app/
Drag options to blanks, or click blank then click option'
A.
Bsrc/
Cnode_modules/
Dbuild/
Attempts:
3 left
💡 Hint
Common Mistakes
Copying the entire current directory (.) adds unnecessary files.
4fill in blank
hard

Fill both blanks to create a multi-stage Dockerfile that builds and then copies only the final app.

Docker
FROM node:16-alpine AS builder
RUN npm install && npm run build
FROM alpine:latest
COPY --from=builder [1] [2]
Drag options to blanks, or click blank then click option'
A/app/build
B/app
C/usr/src/app
D/build
Attempts:
3 left
💡 Hint
Common Mistakes
Copying the entire source directory or wrong paths.
5fill in blank
hard

Fill all three blanks to write a Dockerfile snippet that cleans up after installing packages and sets a working directory.

Docker
FROM alpine:latest
RUN apk add --no-cache git [1] && [2]
WORKDIR [3]
Drag options to blanks, or click blank then click option'
Abash
Brm -rf /var/cache/apk/*
C/app
Dcurl
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to clean cache or setting wrong working directory.