Hi,
EX180 exam has 2 objectives as follows:
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.
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.
Thank you Marek
Red Hat
Learning Community
A collaborative learning environment, enabling open source skill development.