Cloud Computing
Docker
Subjective
Sep 30, 2025
Explain multi-stage builds and their benefits.
Detailed Explanation
Multi-stage builds allow using multiple FROM statements in Dockerfile to create optimized images. Benefits: 1) Smaller final images, 2) Separation of build and runtime dependencies, 3) Better security (no build tools in production), 4) Simplified CI/CD pipelines. Example: Build stage uses node:14 AS builder with WORKDIR /app, COPY package.json, RUN npm install, COPY and RUN npm run build. Production stage uses nginx:alpine, COPY --from=builder /app/dist /usr/share/nginx/html, EXPOSE 80, CMD nginx. This reduces image size from ~1GB to ~50MB.
Discussion (0)
No comments yet. Be the first to share your thoughts!
Share Your Thoughts