What’s the difference between ADD and COPY instructions in the Dockerfile

docker

Isn't clear to me, why there are two instructions for copying files into the Docker image described in the Dockerfile reference. There are ADD and COPY and they seem pretty similar to me. Is there a practical difference between them? If not, which one is most used?

Best Answer

ADD performs a lot more “magic”: it fetches URLs and unpacks archives. That can be somewhat unexpected (especially the archive unpack). The official best practices guide recommends you use COPY unless you need ADD's extra features.

Related Question