0
0
Dockerdevops~10 mins

Choosing small base images (alpine, slim) 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 to use a small base image for a Python app.

Docker
FROM python:[1]
COPY app.py /app/
CMD ["python", "/app/app.py"]
Drag options to blanks, or click blank then click option'
Alatest
Balpine
Cbuster
Dwindows
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing 'latest' results in a larger image.
Using 'windows' is not suitable for Linux containers.
2fill in blank
medium

Complete the Dockerfile to use a slim version of Node.js base image.

Docker
FROM node:[1]
WORKDIR /app
COPY package.json ./
RUN npm install
COPY . .
CMD ["node", "index.js"]
Drag options to blanks, or click blank then click option'
Abuster
Balpine
Cstretch
Dslim
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'alpine' may cause compatibility issues with some Node.js packages.
3fill in blank
hard

Fix the error in the Dockerfile to use Alpine base image for a Go app.

Docker
FROM golang:[1]
WORKDIR /go/src/app
COPY . .
RUN go build -o app
CMD ["./app"]
Drag options to blanks, or click blank then click option'
Awindows
Blatest
Calpine
Dbuster
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'windows' causes incompatibility with Linux commands.
Using 'latest' results in a larger image.
4fill in blank
hard

Fill both blanks to create a Python dictionary comprehension that filters packages by size and uses a small base image.

Docker
packages = {pkg: size for pkg, size in package_sizes.items() if size [1] 50 and pkg.startswith('[2]')}
Drag options to blanks, or click blank then click option'
A<
B>
Calpine
Dslim
Attempts:
3 left
💡 Hint
Common Mistakes
Using '>' filters larger packages.
Using 'slim' does not match the package prefix in this example.
5fill in blank
hard

Fill all three blanks to create a Dockerfile snippet that uses a small base image, sets working directory, and runs a command.

Docker
FROM [1]
WORKDIR [2]
CMD ["[3]"]
Drag options to blanks, or click blank then click option'
Apython:alpine
B/app
Cpython
Dnode:slim
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'node:slim' with Python commands causes errors.
Not setting a working directory can cause file path issues.