Complete the Dockerfile line to use a minimal base image.
FROM [1]Using alpine:latest as the base image helps reduce image size because Alpine Linux is very small and lightweight.
Complete the command to remove unnecessary package lists after installation to reduce image size.
RUN apk add --no-cache curl && rm -rf [1]Removing /var/cache/apk/* clears cached package files, reducing image size.
Fix the error in the Dockerfile line to combine commands and reduce image layers.
RUN apt-get update && apt-get install -y curl [1] apt-get cleanUsing && chains commands so the next runs only if the previous succeeds, combining steps into one layer.
Fill both blanks to create a multi-stage build that copies only the final binary.
FROM golang:1.20 AS builder RUN go build -o app . FROM [1] COPY --from=builder [2] /app
The final stage uses alpine:latest for a small image, and copies the built binary /app/app from the builder.
Fill all three blanks to create a Dockerfile snippet that cleans cache and removes build dependencies.
RUN apt-get update && apt-get install -y build-essential curl && \
make build && \
apt-get purge -y [1] && \
rm -rf [2] && \
apt-get autoremove -y && \
rm -rf [3]Removing build-essential and cleaning /var/lib/apt/lists/* and /tmp/* reduces image size by deleting build tools and cache.