Skip to content
_CORE
AI & Agentic Systems Core Information Systems Cloud & Platform Engineering Data Platform & Integration Security & Compliance QA, Testing & Observability IoT, Automation & Robotics Mobile & Digital Banking & Finance Insurance Public Administration Defense & Security Healthcare Energy & Utilities Telco & Media Manufacturing Logistics & E-commerce Retail & Loyalty
References Technologies Blog Know-how Tools
About Collaboration Careers
CS EN DE
Let's talk

Docker Multi-Stage Builds

09. 06. 2025 Updated: 24. 03. 2026 1 min read intermediate

Docker Multi-Stage Builds

Multi-stage build: build tools in the first stage, result in the final one. Dramatically smaller images.

Node.js

FROM node:18 AS builder WORKDIR /app COPY package*.json ./ RUN npm ci COPY . . RUN npm run build FROM nginx:alpine COPY –from=builder /app/dist /usr/share/nginx/html

40 MB instead of 1.2 GB

Go

FROM golang:1.22 AS builder WORKDIR /app COPY . . RUN CGO_ENABLED=0 go build -o server . FROM scratch COPY –from=builder /app/server /server ENTRYPOINT [“/server”]

15 MB

Python

FROM python:3.12 AS builder COPY requirements.txt . RUN pip install –user –no-cache-dir -r requirements.txt FROM python:3.12-slim COPY –from=builder /root/.local /root/.local COPY . . CMD [“python”, “app.py”]

  • Name your stages (AS builder)
  • Dependency files first -> better cache
  • alpine/slim/scratch base
  • Use .dockerignore

Smaller = Better

Multi-stage = smaller image, smaller attack surface, faster pull.

dockermulti-stagebuild
Share:

CORE SYSTEMS team

We build core systems and AI agents that keep operations running. 15 years of experience with enterprise IT.