Skip to content

no-copy-whole-stage

Dockerfilesuspiciousno fixdefault: offdockerfile/hadolint

Reports a COPY --from=stage / /, which copies the whole file system of a stage to /. A copy of / into a folder (/app/) or of a folder is not reported.

It copies everything of the build stage: compilers, package caches, sources, and the stage’s own /etc and /usr over the ones of the final image. The image becomes as large as the build stage, which defeats the purpose of a multi-stage build, and files of the base image are overwritten.

Copy only what the final image needs: COPY --from=build /out/app /usr/local/bin/.

Reported
...
COPY --from=0 / /
...
COPY a b /dest/
COPY a /dest
...
dockerfile:
lint:
rules:
no-copy-whole-stage: warn # off (default), warn, error

Enabled by the presets: dockerfile/hadolint.

Suppress one line with sudsy-disable-next-line no-copy-whole-stage in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
hadolint DL3067 full