Skip to main content
Use COPY instead of ADD for files and folders.

Description

For files and directories that do not require ADD’s tar auto-extraction capability, you should always use COPY. COPY is more transparent and predictable than ADD, since it only supports basic copying of files into the container. Exception: ADD is appropriate for local tar file auto-extraction into the image.

Examples

Problematic code

Correct code

Auto-fix

Replaces the ADD keyword with COPY, preserving all flags, sources, and destination unchanged.
  • Safe fix (FixSafe): Always correct for local file/directory sources since COPY and ADD behave identically for non-URL, non-tar sources.
The fix preserves instruction casing (ADDCOPY, addcopy).

Reference