Docker and CI/CD · Middle · Question 4 of 75
Why does RUN rm -rf /tmp/build in a later layer not shrink the image?
- 1Docker restores deleted files when the container starts
- ✓Correct answer: Earlier layers still contain the files; deletion only hides them
- 3
rmis not allowed inRUNinstructions
Explanation
Layers are additive. Clean up in the same RUN that created the files, or use a multi-stage build so temporary files never reach the final image.