Use COPY
ADD has more "hidden" features than COPY, so use COPY if you don't have the other needs when copying files.
ADD and Its Magic Feature
For example, ADD would untar and un-compress files if docker detects the file is a (compressed) tarball. This
feature is handy when you create a docker image based on Ubuntu image and docker scratch "image".
Let's use Ubuntu Jammy cloud image to build a docker image. Firstly, download the cloud image:
wget https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-arm64-root.tar.xz
and build this Dockerfile
FROM scratch
ADD jammy-server-cloudimg-arm64-root.tar.xz /
by
docker build .
After building the image successfully, "login" into the container based on your docker image and you can see the
file system of an Ubuntu cloud image, rather than a tarball file a.k.a. jammy-server-cloudimg-arm64-root.tar.xz.
Besides, you will have bash shell ready to use, which you won't have with simply scratch image.
Reference
My point of view is similar to this article.