Multi-stage build boundaries
Multiple FROM instructions define stages. A final stage can copy selected artifacts from a builder while leaving compilers, source caches, and development tools behind. Stage naming makes copying and targeted builds clearer. The final artifact still needs its necessary runtime libraries and configuration. For example, cOPY --from=builder /out/app /app copies only the built artifact into the runtime stage.
COPY --from=builder /out/app /app copies only the built artifact into the runtime stage.
A compiled application needs a compiler, development headers, and source files to produce its executable. A builder stage contains those tools and writes the artifact to a known output directory. A later runtime stage begins from another base and copies only the needed artifact and runtime files. The builder's entire filesystem is not automatically shipped.
A stage is a build environment started by FROM. An artifact is the selected output to distribute. COPY --from transfers files from another stage. Name stages so references are understandable and refactoring does not depend on numeric ordering. Multi-stage design reduces shipped tooling, but the application may still need libraries, certificates, time-zone data, or a compatible runtime. Test the final stage rather than only the builder. An artifact compiled for a different architecture or incompatible library environment can exist at the right path yet fail immediately when the container starts.
COPY --from=builder /out/app /app copies only the built artifact into the runtime stage.
Do not overlook this operational distinction: The final artifact still needs its necessary runtime libraries and configuration.