Multi-stage Dockerfile vocabulary

  • FROM image AS name — names a stage; later stages copy from it with COPY --from=name
  • COPY --from=builder — copies files from another stage's filesystem, not the host
  • ENTRYPOINT = fixed executable; CMD = overridable default arguments (appended to ENTRYPOINT)
  • Combine RUN apt-get update && install — prevents stale cache; clean up in the same layer
  • .dockerignore — excludes files from build context; prevents secret leaks and reduces build size

Question 0 of 5

Read this multi-stage Dockerfile. Identify the builder stage and the final stage:

FROM node:20-alpine AS builder WORKDIR /app COPY package*.json ./ RUN npm ci COPY . . RUN npm run build FROM node:20-alpine WORKDIR /app COPY --from=builder /app/dist ./dist COPY --from=builder /app/node_modules ./node_modules EXPOSE 3000 CMD ["node", "dist/server.js"]