I explained the difference between copy and add command in docker file in simple and easy way.
Overview of copy and add command
In docker, if we are taking about Copy
and Add
command both work similar but there is a small difference between these commands.
copy
command is used to copy source file/directory into destination docker directory.- In case of
add
command will perform same task to copy from source file/directory into destination docker directory . But most probably add is used when we need to get file from URL and extract it to particular docker directory .
Syntax of copy and add
Let me share the syntax for both copy
Copy mySrc.tar.gz /usr/myfolder
- this only copy the source file to destination
ADD mySrce.tar.gz /usr/myfolder/.
Add URL/abc.tar.gx /usr/myfolder/.
It will copy same in extract the get from URL and tar.gz
file to destination folder. So single command perform multiple tasks.
Happy Learning 🙂