When to use ADD or COPY to copy files to a Dockerfile?

2

The Dockerfile syntax has two instructions for copying files: ADD and COPY . Both copy files to the container. When to use each?

    
asked by anonymous 04.05.2017 / 21:14

1 answer

2

The application will depend on what you are trying to transfer to the container. According to this response in SOen , the biggest difference from the ADD method to COPY is:

  • Method ADD allows the SRC attribute to be URL
  • If the file entered in the SRC attribute of the ADD method has a recognized compression format, it will be unmapped.

There is own documentation for the Docker: ADD or COPY

where it informs the same thing, and that it is preferable to use the COPY method because it is transparent.

That is, if you will not use the remote transfer and decompression feature, use the COPY method.

    
04.05.2017 / 21:30