Skip to content

copy-many-needs-directory

Dockerfilecorrectnessno fixdefault: errordockerfile/hadolint

Reports a COPY with several sources whose destination does not end with / (COPY a b /app). The JSON form, a single source and a heredoc (<<) are not checked.

With several sources the destination must be a directory, and Docker takes a destination without a trailing slash for a file name. The build stops with an error that the destination of a copy of several sources must end with /.

Reported
...
COPY a b /dest
COPY a b /dest/
COPY a /dest
...
dockerfile:
lint:
rules:
copy-many-needs-directory: error # off, warn, error (default)

Enabled by the presets: dockerfile/hadolint.

Suppress one line with sudsy-disable-next-line copy-many-needs-directory in a comment of the file’s language.

The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.

Tool Rule Match What differs
hadolint DL3021 partial The shell form only; the JSON form is not checked.