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?
✗ Incorrect
Alpine is a minimal Linux distribution designed to be small and secure, making it popular for small Docker images.
What is the benefit of combining multiple RUN commands into a single RUN command in a Dockerfile?
✗ Incorrect
Combining RUN commands reduces the number of layers, which helps reduce the final image size.
What does a multi-stage Docker build allow you to do?
✗ Incorrect
Multi-stage builds let you separate build and runtime environments, copying only necessary files to keep the final image small.
Why should you clean up package manager caches in a Dockerfile?
✗ Incorrect
Package manager caches are temporary files that increase image size if not removed.
What is the purpose of the .dockerignore file?
✗ Incorrect
The .dockerignore file tells Docker which files to ignore when sending the build context, helping reduce image size.
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.