Docker - Image OptimizationWhich Dockerfile instruction helps reduce image size by cleaning up after package installation?ACMD ["python", "app.py"]BRUN apt-get update && apt-get install -y package && rm -rf /var/lib/apt/lists/*CEXPOSE 80DCOPY . /appCheck Answer
Step-by-Step SolutionSolution:Step 1: Identify cleanup commands in RUN instructionThe command removes package cache files after installation to reduce image size.Step 2: Recognize other instructions do not clean upCOPY, EXPOSE, and CMD do not affect image size cleanup.Final Answer:RUN apt-get update && apt-get install -y package && rm -rf /var/lib/apt/lists/* -> Option BQuick Check:Cleanup after install = RUN with rm command [OK]Quick Trick: Clean package cache in same RUN to reduce image size [OK]Common Mistakes:Not cleaning cache after package installUsing COPY or CMD for cleanup
Master "Image Optimization" in Docker9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More Docker Quizzes Docker Security - Secrets management - Quiz 12easy Docker Security - Secrets management - Quiz 14medium Image Optimization - Analyzing image layers with dive - Quiz 8hard Image Optimization - Reducing image size strategies - Quiz 3easy Logging and Monitoring - Docker events monitoring - Quiz 1easy Logging and Monitoring - Centralized logging setup - Quiz 9hard Production Patterns - Container orchestration in production - Quiz 11easy Production Patterns - Backup and restore strategies - Quiz 6medium Production Patterns - Sidecar container pattern - Quiz 9hard Resource Management - Resource monitoring per container - Quiz 3easy