If we use the command COPY docker file copies from local source to destination in the docker container. At the same time ADD command copy file / directories into the Docker image. ADD can also copy files from a URL.
It copies the files from the host system to the Docker image. COPY command only accept the local files.
$ COPY /home/thelinuxfaq/sample/files /app
Just copying file using ADD:
It copies the files from the host system to the Docker image.
$ ADD /home/thelinuxfaq/Desktop/app /app
To extract the tarfiles from local machine:
The ADD command is more different than COPY. It can auto-extract tar files from the local machine using the following command.
$ ADD /home/thelinuxfaq/sample.tar.gz /app
To download a directory or a file from a URL:
ADD can accept a remote URL for its source argument. If we use ADD to fetch remote files and copying, it will increase the overall Docker image size. Instead, we should use curl or wget to fetch remote files and use ADD to expand tar files into the image file system. While this can reduce the number of Dockerfile steps required to build an image.
$ ADD https://www.thelinuxfaq.com/post-images/7071-filezilla-install.png /app