copy-instead-of-add
What it does
Section titled “What it does”Reports an ADD that only copies. That is an ADD with no URL (http://, https://) and no archive (a name ending in .tar, .gz, .tgz, .xz, .bz2 and the like) among its arguments.
Why it matters
Section titled “Why it matters”ADD does more than copy: it unpacks local tar archives and downloads URLs. For a plain file or folder that is a surprise, since an archive you meant to copy is extracted and a value that turns out to be a URL starts a download. COPY only copies, so the instruction says what happens.
Keep ADD for unpacking an archive into the image.
Example
Section titled “Example”...COPY a b /dest/COPY a /destADD app.js /app/ADD app.tar.gz /app/ADD https://example.com/f /app/...Configuration
Section titled “Configuration”dockerfile: lint: rules: copy-instead-of-add: warn # off (default), warn, errorEnabled by the presets: dockerfile/hadolint.
Suppress one line with sudsy-disable-next-line copy-instead-of-add in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”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 | DL3020 |
partial | Reports an ADD with no URL and no archive among its arguments; hadolint reports one source that is neither. |