# What Is the Difference between the ‘COPY’ and ‘ADD’ Commands in a Dockerfile?

When creating a Docker file, you may need to transfer some files from the host system to the docker image. Those files may be for example libraries or any other files that your application may need at runtime.

To do that, docker provides two commands - `COPY` and `ADD`

## What is the difference?

Both `COPY` and `ADD` commands allow you to add files to your docker image from a specific location. Both of these commands take to arguments `<src>` (location of the source file) and `<dest>` (copy destination).

In the case of the `COPY` command, it only allows you to copy files from the local machine (the machine creating the Docker image).

Whereas `ADD` command allows the source path to be a URL address. It can also extract tar files from the source to the destination.

## Which one should you use?

It is a best practice to always prefer `COPY` over `ADD` unless you especially need one of the additional features of `ADD`. As mentioned above, `ADD` command automatically expands which can lead to unexpected wiles being written to the docker image.
