The difference and continuity between docker's ADD command and COPY command

Difference between Docker's ADD command and COPY command

Both ADD and COPY commands of Docker can copy local files into the container, but there are still some differences between the two:

  1. The ADD command can automatically decompress (*.tar, *.tar.gz, *.tar.bz2, *.tar.xz, *.zip), but the COPY command cannot.
  2. The ADD command can copy files by URL, but the COPY command cannot.
  3. The ADD command can directly decompress the tar file to the target directory, while the COPY command needs to decompress the tar file to the local and then copy it to the target directory.

Continuous use of Docker's ADD command and COPY command

In Dockerfile, ADD and COPY commands can be used consecutively, for example:

 
 

plaintextCopy code

COPY aaa.txt /app/ ADD bbb.tar.gz /app/

Here first copy the local aaa.txt file to the /app/ directory, and then unzip the local bbb.tar.gz file and copy it to the /app/ directory. Note that if there is a file identical to aaa.txt in bbb.tar.gz, it will be overwritten.

Guess you like

Origin blog.csdn.net/ihateright/article/details/131166140