Skip to content

Difference between COPY and ADD in a Dockerfile

Learn the difference between copy and add instructions in dockerfile.To start with, both copy and add instructions are used to copy files from a source into the docker image.


ADD instruction copies everything from the source including the file system metadata to the destination.


ADD <src> … <dest>

When you copy a compressed file using ADD, it automatically extracts the compressed file’s content into the destination if the compressed file is of a recognized compression format (zip, xz, bzip, gzip).


ADD /ngroktemp

ADD /home/ /dockerhome/installer


COPY command copies the source to the destination in the same format the source is.


COPY <src> … <dest>

It doesn’t work with URLs and it doesn’t extract compressed files but only copies them.


COPY /home/inputs/  /dockerhome/inputs

As a final note, always prefer using COPY as it’s more transparent that ADD but at the end of the day it depends on what you want to do.

See also  Get names of all running containers in docker

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.