Ads by ProfitSence

Docker Add vs Copy

Last Updated on Wednesday 5th Oct 2022

DockerFile Add vs Copy

  • ADD has more features than COPYand it is suggested to use COPY.
  • 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 the COPY target, you can COPY . /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/ and COPY dir1/ /app/.
  • You CAN NOT copy multiple directories to target directory.