The Dockerfile syntax has two instructions for copying files: ADD
and COPY
. Both copy files to the container. When to use each?
The Dockerfile syntax has two instructions for copying files: ADD
and COPY
. Both copy files to the container. When to use each?
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:
ADD
allows the SRC
attribute to be URL
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 theCOPY
method because it is transparent.
That is, if you will not use the remote transfer and decompression feature, use the COPY
method.