copy-from-unknown-stage
What it does
Section titled “What it does”Reports a COPY --from=name that names no stage defined earlier. Not reported: the number of an earlier stage (--from=0) and an image reference with a : (--from=nginx:1). A stage defined further down does not count. Names are compared without regard to case.
Why it matters
Section titled “Why it matters”Docker does not fail on an unknown name: it takes it for an image and pulls it from the registry. A typo in a stage name (buidler) or a reference to a stage defined further down copies files from whatever image has that name, or fails only when the pull fails.
Example
Section titled “Example”...USER app...COPY --from=build /a /bCOPY --from=nope /a /bCOPY --from=BUILD /a /bCOPY --from=0 /a /bCOPY --from=99 /a /bCOPY --from=alpine:3 /a /bCMD ["a"]...Configuration
Section titled “Configuration”dockerfile: lint: rules: copy-from-unknown-stage: warn # off, warn (default), errorEnabled by the presets: dockerfile/hadolint.
Suppress one line with sudsy-disable-next-line copy-from-unknown-stage in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| hadolint | DL3022 |
full |