0
0
Dockerdevops~5 mins

Reducing image size strategies in Docker - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a common way to reduce Docker image size by choosing the base image?
Use a minimal base image like Alpine Linux instead of a full OS image. Alpine is very small and includes only essential packages.
Click to reveal answer
beginner
How does combining RUN commands in a Dockerfile help reduce image size?
Combining multiple RUN commands into one reduces the number of layers, which lowers the final image size.
Click to reveal answer
intermediate
Why should you remove package manager caches and temporary files in Docker images?
Removing caches and temp files after installing packages prevents unnecessary data from staying in the image, making it smaller.
Click to reveal answer
intermediate
What is a multi-stage build in Docker and how does it help reduce image size?
Multi-stage builds use multiple FROM statements to build in stages. You copy only the final needed artifacts to the last stage, leaving behind build tools and files, reducing image size.
Click to reveal answer
beginner
How can using .dockerignore file help in reducing Docker image size?
The .dockerignore file excludes unnecessary files and folders from the build context, so they are not copied into the image, keeping it smaller.
Click to reveal answer
Which base image is known for being very small and commonly used to reduce Docker image size?
ACentOS
BUbuntu
CAlpine
DDebian
What is the benefit of combining multiple RUN commands into a single RUN command in a Dockerfile?
AReduces the number of image layers
BSpeeds up container startup time
CIncreases image caching
DImproves network security
What does a multi-stage Docker build allow you to do?
ACompress images after build
BRun multiple containers from one image
CAutomatically update base images
DBuild images in stages and copy only needed files to the final image
Why should you clean up package manager caches in a Dockerfile?
ATo speed up package installation
BTo reduce image size by removing unnecessary files
CTo improve container security
DTo enable automatic updates
What is the purpose of the .dockerignore file?
AExclude files from the build context to reduce image size
BSpecify environment variables for the container
CDefine network settings for the container
DList commands to run after container start
Explain three strategies to reduce Docker image size and why they work.
Think about base image choice, Dockerfile commands, and cleanup steps.
You got /3 concepts.
    Describe how multi-stage builds help in creating smaller Docker images.
    Focus on separating build environment from final image.
    You got /4 concepts.