Optimize this Dockerfile to reduce deployment time without changing application behavior. Which two actions should you take? (Choose two.)
Choose an answer
Tap an option to check your answer.
Correct answer: Use a slimmed-down base image like Alpine Linux, Copy the source after the package dependencies (Python and pip) are installed.
Why this is the answer
Using a slimmed-down base image like Alpine Linux significantly reduces the image size, leading to faster pulls and deployments. Alpine images are much smaller than their Debian or Ubuntu counterparts because they use musl libc and contain only essential utilities. Copying the source after package dependencies are installed leverages Docker's build cache effectively. If only the source code changes, Docker can reuse the cached layers for dependency installation, avoiding a full rebuild of those layers and speeding up subsequent builds. Removing Python after running pip is generally not feasible as Python is needed at runtime. Removing dependencies from requirements.txt would alter application behavior. Using larger machine types for GKE node pools affects runtime performance, not deployment time.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed