Docker - SecurityWhich Dockerfile snippet correctly creates a non-root user 'appuser' with UID and GID 1500 and sets it as the container user?ARUN useradd -r appuser USER 1500BRUN addgroup -g 1500 appuser && adduser -u 1500 -G appuser -D appuser USER appuserCUSER appuser RUN groupadd -g 1500 appuserDRUN adduser appuser USER rootCheck Answer
Step-by-Step SolutionSolution:Step 1: Create group and user with specific IDsUse addgroup and adduser with -g and -u flags to set GID and UID.Step 2: Set USER to 'appuser'USER instruction sets the container runtime user.Step 3: Verify other optionsRUN useradd -r appuser USER 1500 lacks group creation and uses USER with UID only; C sets USER before group; D sets USER to root.Final Answer:RUN addgroup -g 1500 appuser && adduser -u 1500 -G appuser -D appuser USER appuser -> Option BQuick Check:Create user/group with IDs, then set USER [OK]Quick Trick: Create user/group with IDs, then USER [OK]Common Mistakes:Setting USER before creating userNot specifying UID/GID explicitlyRunning container as root unintentionally
Master "Security" in Docker9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More Docker Quizzes Docker Swarm - Overlay networks in Swarm - Quiz 13medium Docker Swarm - Rolling updates - Quiz 15hard Docker in CI/CD - Why Docker in CI/CD matters - Quiz 12easy Image Optimization - Reducing image size strategies - Quiz 3easy Image Optimization - Analyzing image layers with dive - Quiz 15hard Image Optimization - Why image optimization matters - Quiz 15hard Production Patterns - Canary deployment pattern - Quiz 2easy Production Patterns - Why production patterns matter - Quiz 14medium Production Patterns - Backup and restore strategies - Quiz 2easy Production Patterns - Container orchestration in production - Quiz 6medium