Pattern: Use of ADD
instead of COPY
Issue: -
Generally speaking, COPY
is preferred because it’s more transparent. ADD
has some features (like local-only tar extraction and remote URL support) that are not immediately obvious. Consequently, the best use for ADD
is local tar file auto-extraction into the image, as in ADD rootfs.tar.xz /
.
Example of incorrect code:
FROM python:3.4
ADD requirements.txt /usr/src/app/
Example of correct code:
FROM python:3.4
COPY requirements.txt /usr/src/app/