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
| Name | Type | Description |
|---|---|---|
| stage-or-image | string | Named stage, index or reviewed image. |
| source | string | Source filesystem path. |
| destination | string | Receiving 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"]