Complete the Dockerfile line to use a smaller base image.
FROM [1]Using alpine:latest as the base image reduces the image size significantly because Alpine is a minimal Linux distribution.
Complete the command to remove unnecessary package cache after installation.
RUN apk add --no-cache curl && rm -rf [1]Removing /var/cache/apk/* clears the package cache, reducing image size.
Fix the error in the Dockerfile line to reduce layers by combining commands.
RUN apk add curl \
&& [1] /var/cache/apk/*Using rm -rf removes the cache in the same layer, reducing final image size.
Fill both blanks to create a multi-stage Dockerfile that copies only the final binary.
FROM golang:1.20-alpine AS builder WORKDIR /app COPY . . RUN go build -o [1] . FROM alpine:latest COPY --from=builder /app/[2] /usr/local/bin/ CMD ["[3]"]
The binary is named main in the build step and copied from the builder stage. The command runs main.
Fill all three blanks to create a Dockerfile that cleans up build tools and reduces image size.
FROM node:18-alpine AS build WORKDIR /app COPY package.json . RUN npm install COPY . . RUN npm run build FROM alpine:latest RUN apk add --no-cache [1] COPY --from=build /app/dist /app CMD ["[2]", "[3]"]
The final image installs only node to run the app. The CMD runs serve index.js to start the app.