Test your understanding of the concepts covered in the Modern Docker & Best Practices chapter.
Q1. What is the primary technical benefit of multi-stage builds in a Dockerfile?
Explanation
Multi-stage builds separate build-time dependencies (compilers, devDependencies) from runtime requirements, yielding significantly smaller, more secure images.
Q2. Why can building a Docker image on an Apple Silicon Mac (M1/M2/M3/M4) without specifying a platform cause an `exec format error` when deployed to a standard AWS EC2 server?
Explanation
Apple Silicon Macs use ARM64 CPUs, whereas standard cloud servers use AMD64/x86_64. Using `docker buildx build --platform linux/amd64` ensures cross-building for cloud x86 hosts.
Q3. What feature introduced in Docker Compose V2 automatically monitors source code edits and intelligently syncs files or rebuilds services in real time?
Explanation
`docker compose watch` monitors project files and automatically syncs code changes into running containers or rebuilds services when dependency manifests change.
Q4. Why is running containers under a non-root user account (`USER appuser` in Dockerfile) a critical security best practice?
Explanation
Running as non-root limits the blast radius of potential container escape exploits, ensuring an attacker cannot obtain root privileges on the underlying host.
Q5. Which built-in Docker CLI tool allows developers to scan Docker images for security vulnerabilities (CVEs) and base image update recommendations?
Explanation
`docker scout` (e.g. `docker scout quickview` or `docker scout cves`) analyzes image layers and reports known vulnerabilities and patch recommendations.