Which of the following is the main advantage of using minimal base images like alpine in Docker containers?
Think about what affects container download and deployment speed.
Minimal base images like Alpine are very small, which reduces the image size. Smaller images download faster and start quicker, which is a key benefit in container environments.
What is the output of the following command if you have a Docker image named myapp built from alpine base?
docker images myapp --format "{{.Repository}}: {{.Size}}"Alpine base images are known for being very small, around 5MB.
Alpine base images are typically around 5MB, so images built on top of Alpine tend to be small unless large layers are added.
Which Dockerfile snippet correctly uses multi-stage builds to reduce the final image size by excluding build tools?
FROM golang:1.20 AS builder WORKDIR /app COPY . . RUN go build -o myapp FROM alpine:latest COPY --from=builder /app/myapp /usr/local/bin/myapp ENTRYPOINT ["myapp"]
Look for copying only the necessary files from the builder stage.
Multi-stage builds allow compiling in one stage and copying only the final binary to a minimal base image, reducing the final image size.
You notice your Docker image size is unexpectedly large. Which of the following is the most likely cause?
Think about what adds extra weight to an image.
Including unnecessary packages and files increases image size. Minimal base images and multi-stage builds help reduce size, and removing cache also helps.
Which Dockerfile approach best minimizes image size for a Python application?
FROM python:3.12-slim WORKDIR /app COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt COPY . . CMD ["python", "app.py"]
Consider both base image size and package installation options.
Using the slim base image reduces base size, and --no-cache-dir prevents pip from storing cache files, minimizing final image size.