As per this the following reference https://docs.docker.com/engine/reference/builder/#copy I see no difference between ADD and COPY. Please help me with a simple example explaining the difference.
Asked
Active
Viewed 1.5k times
12
-
13Possible duplicate of [Docker COPY vs ADD](http://stackoverflow.com/questions/24958140/docker-copy-vs-add) – Naftali Sep 12 '16 at 16:16
-
1Duplicate of https://stackoverflow.com/questions/24958140 – Ashish Awasthi Jun 30 '17 at 02:05
2 Answers
18
Found the answer here: Docker COPY vs ADD
- ADD allows
<src>
to be an URL - If the
<src>
parameter of ADD is an
archive in a recognized compression format, it will be unpacked

Community
- 1
- 1

Priyanka.Patil
- 1,177
- 2
- 15
- 34
-
1https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/#add-or-copy – dimpiax Apr 28 '17 at 17:08
4
From Docker online documentation :
ADD or COPY
Although ADD and COPY are functionally similar, generally speaking, COPY is preferred. That’s because it’s more transparent than ADD. COPY only supports the basic copying of local files into the container, while ADD has some features (like local-only tar extraction and remote URL support) that are not immediately obvious. Consequently, the best use for ADD is local tar file auto-extraction into the image, as in ADD rootfs.tar.xz /.
More information can be found at Best Practices for writing Dockerfiles
Basically,
Use COPY for plain files and/or directories copy,
Use ADD for extracting TAR archives or downloading remote content,