R's Workshop

Difference between Docker ADD and COPY commands

這篇紀錄一下 Dockerfile 中 ADDCOPY 使用上的差異. 先講結論: 除了新增一個需要解壓縮的檔案到 image 時使用 ADD 外, 絕大部分的情況下都建議使用 COPY.

ADD

COPY

Common Characteristics

This equals to

COPY go/* /usr/local/


* 如果 `<src>` 是資料夾, 則 `<dest>` 是一個非 `/` 結尾且不存在的位址, 則 Docker 會新建一個 `<dest>` 資料夾, 並把 `<src>` 資料夾下所有的內容搬過去
```Dockerfile
# Copy go directory to /usr/local
COPY go /usr/local/go

Reference

container Docker