DockerFile Add vs Copy
-
ADD
has more features thanCOPY
and it is suggested to useCOPY
. -
COPY
only supports the basic copying of local files into the container. -
ADD
has some features (like remote URL support)
Docker Add
- src can be a URI
- src can be a tar file. If the compression format is recognized, then the tar file will be automatically unpacked.
Docker Copy
FROM debian:10 ADD wordpress-latest.tar.gz /app/er RUN find /app
Above will extract the
tar.gz
package and place it under
/app/er
.
-
ADD
allows<src>
to be a URL
Docker Copy Command
- You don't need to
RUN``mkdir abc
for theCOPY
target, you canCOPY
. /a/b and docker will create directories for you. - Directory and Slash. You do need to add slash for command like
COPY dir1 /app
. - It will copy all content in
dir1
to/app
, you won't get path like/app/dir1
. - It is same as
COPY dir1 /app/
andCOPY dir1/ /app/
. - You CAN NOT copy multiple directories to target directory.