Connect with us


Docker ADD vs COPY vs VOLUME – [2023]

Let’s Learn Docker ADD vs COPY vs VOLUME with Simple Examples :

We’ll learn in this tutorial the differences between Docker ADD vs COPY vs VOLUME when configuring Dockerfiles.

They all accomplish the same task (among other capabilities): moving files from the host computer to a Docker container.


VOLUME is different from COPY and ADD because it creates a mount point that the host operating system can interact with.

This command syncs the Docker container’s /var/www directory with the host OS’s cool-project directory. When any change is made to cool-project within the host OS it is immediately made available to the docker container mounting that directory and vice versa.

Docker ADD vs COPY

Using VOLUME is especially useful for development environments where frequent modifications to the code are being made. For example, running nodemon on a Docker container with a VOLUME allows you to make changes to your code that are immediately reflected as if Docker were invisible.


COPY accomplishes everything that VOLUME accomplishes, but does it during build time. This is necessary for configuring containers with modified config files with services such as httpd, Nginx, MongoDB, etc… For example when configuring an Nginx container modifying the nginx.conf file is an operation that must be done with COPY.

One setback to COPY is that it makes only the container that was copied to aware of the contents. Meaning we cannot access the contents on our host computer, or on other running docker containers, something VOLUME does.

Docker  COPY vs ADD


ADD is exactly the same as COPY except for one distinct difference. ADD can fetch content from a URL and it will not extract the content, only downloading to the specific location. Check the bellow example.

If the local content is recognized as compressed, will uncompress the contents. Check the bellow example.

It has the same setbacks that COPY has.

This is the Dockerfile we used for the above Examples.

What do I do?

I use Volumes by default whenever I can so that I don’t have to rebuild my Docker container every time there’s a modification to the code.

So this is the ending of the Docker ADD vs COPY vs VOLUME Article. we will appreciate your feedback and check out our new article about mail Command in Linux.

Continue Reading
1 Comment

1 Comment

Leave a Reply

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