Docker - Image OptimizationWhich of the following Dockerfile RUN commands correctly cleans up the apt cache to minimize image size?ARUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*BRUN apt-get update && apt-get install -y curl && apt-get cleanCRUN apt-get update && apt-get install -y curlDRUN apt-get install -y curl && rm -rf /var/cache/aptCheck Answer
Step-by-Step SolutionSolution:Step 1: Update and install packagesThe command starts with 'apt-get update' and installs curl.Step 2: Remove apt cache filesRemoving '/var/lib/apt/lists/*' deletes the package lists, reducing image size.Final Answer:RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/* -> Option AQuick Check:Cache removal after install reduces image size [OK]Quick Trick: Remove apt lists after install to reduce image size [OK]Common Mistakes:Not removing apt cache files after installationUsing separate RUN commands causing extra layersOnly running apt-get clean without removing lists
Master "Image Optimization" in Docker9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More Docker Quizzes Docker Security - Secrets management - Quiz 2easy Docker Security - Read-only filesystem containers - Quiz 7medium Docker Swarm - Why orchestration matters - Quiz 3easy Docker Swarm - Why orchestration matters - Quiz 15hard Docker Swarm - Deploying services in Swarm - Quiz 3easy Image Optimization - Scratch base image for minimal containers - Quiz 15hard Logging and Monitoring - Docker events monitoring - Quiz 13medium Resource Management - CPU limits and reservations - Quiz 12easy Resource Management - Resource monitoring per container - Quiz 15hard Resource Management - CPU limits and reservations - Quiz 13medium