InterviewSolution
| 1. |
What is the difference between ADD and COPY in Dockerfile? |
|
Answer» The ADD instruction is used to copy files from build context to the image. Apart from regular files, it also allows URL and archive (tar, gzip, etc) files as the <source> parameter. When a URL is provided, a file is downloaded from the URL and copied to the <destination>.It automatically unpacks compressed files, if the <source> argument is a local file in a recognized compression format (tar, gzip, bzip2, etc). Whereas COPY does a straight-forward, as-is copy of files and folders from the build context into the container. It doesn't support URLS or gives any special treatment to archives. Anything that you want to COPY into the container MUST be PRESENT in the local build context. The recommendation from the Docker team is to use COPY in almost all CASES. |
|