
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- 1,585 Views
ADD vs COPY
Hi,
EX180 exam has 2 objectives as follows:
- Understand and use ADD instruction.
- Understand and use COPY instruction.
I am trying to understand when to use which one... Since ADD has more capability then COPY such as supporting copying from URL and/or the archive functionality, what would be the use case to prefer COPY over ADD when we can just simply use ADD. In other words why do we have COPY when we can use ADD?
thanx.


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- 1,472 Views
In general, I would recommend you use COPY whenever applicable, and only use ADD when you explicitly need one of its additional use cases.
Typically with ADD, you'll still need to do some cleanup, like deleting downloaded resources, in which case you might as well download the resource with the RUN instruction and chain the commands.
Using ADD by default means that developers might encounter unexpected behavior, such as adding tar file and noticing that it's actually expanded when that wasn't the intent.
Explicit is always better than implicit, which is why I would recommend using COPY instead of ADD when applicable. This is recommended by Docker as well.
HTH,
M.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- 1,456 Views
Thank you Marek