Docker ADD vs COPY


Docker best practice:

Prefer COPY over ADD when copying files from a location to a Docker image.

Use ADD to:

  1. download external files
  2. extract an archive to the destination

👇

# copy local files on the host to the destination
COPY /source/path  /destination/path
ADD /source/path  /destination/path

# download external file and copy to the destination
ADD http://external.file/url  /destination/path

# copy and extract local compresses files
ADD source.file.tar.gz /destination/path