0
0
Dockerdevops~10 mins

Image size and minimal base images 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 minimal base image for a Python app.

Docker
FROM [1]
COPY app.py /app.py
CMD ["python", "/app.py"]
Drag options to blanks, or click blank then click option'
Anode:latest
Bubuntu:latest
Cdebian:latest
Dpython:3.12-slim
Attempts:
3 left
💡 Hint
Common Mistakes
Using a full OS image like ubuntu increases image size unnecessarily.
Choosing an unrelated base image like node for a Python app.
2fill in blank
medium

Complete the Dockerfile to reduce image size by removing cache after package installation.

Docker
FROM alpine:3.18
RUN apk add --no-cache [1]
CMD ["sh"]
Drag options to blanks, or click blank then click option'
Apython3 --cache
Bpython3
Cpython3 --no-cache
Dpython3-cache
Attempts:
3 left
💡 Hint
Common Mistakes
Adding cache flags as part of the package name causes errors.
Not using --no-cache leads to larger images.
3fill in blank
hard

Fix the error in the Dockerfile to use a minimal base image for a Node.js app.

Docker
FROM [1]
COPY server.js /server.js
CMD ["node", "/server.js"]
Drag options to blanks, or click blank then click option'
Anode:alpine
Bnode:latest
Cnode:slim
Dubuntu
Attempts:
3 left
💡 Hint
Common Mistakes
Using node:latest results in a larger image.
Using ubuntu is not optimized for Node.js apps.
4fill in blank
hard

Fill both blanks to create a Python Dockerfile that uses a minimal base image and installs packages without cache.

Docker
FROM [1]
RUN apk add --no-cache [2]
CMD ["python3"]
Drag options to blanks, or click blank then click option'
Apython:3.12-alpine
Bpython3
C--no-cache
Dpython3-pip
Attempts:
3 left
💡 Hint
Common Mistakes
Using a full Python image increases size.
Not using --no-cache causes larger images.
5fill in blank
hard

Fill all three blanks to create a minimal Dockerfile that copies app files, installs dependencies without cache, and runs the app.

Docker
FROM [1]
COPY [2] /app/
RUN pip install [3] -r /app/requirements.txt
COPY app.py /app/
CMD ["python3", "/app/app.py"]
Drag options to blanks, or click blank then click option'
Apython:3.12-alpine
Bapp.py
C--no-cache-dir
Drequirements.txt
Attempts:
3 left
💡 Hint
Common Mistakes
Copying the app.py instead of requirements.txt before installing dependencies.
Not using --no-cache-dir increases image size.