Dockerfile instructions

COPY --from

Copies from a selected stage or image. Source path starts at that filesystem root; relative destination follows the receiving WORKDIR. Use reviewed sources. A mistyped name may resolve as an external image; stop before unintended resolution.

Formal Syntax & Structure

docker syntaxdocker
COPY --from=<stage-or-image> <source> <destination>

Parameters & Attributes

NameTypeDescription
stage-or-imagestringNamed stage, index or reviewed image.
sourcestringSource filesystem path.
destinationstringReceiving path.

Working Example

Example Snippetdocker
FROM busybox:1.37 AS assembleWORKDIR /buildRUN mkdir /out && printf "version=1\n" > /out/info.txtFROM busybox:1.37WORKDIR /appCOPY --from=assemble /out/info.txt ./info.txtCMD ["cat", "/app/info.txt"]
Docker Reference