This product is not supported for your selected Datadog site. ().
このページは日本語には対応しておりません。随時翻訳に取り組んでいます。
翻訳に関してご質問やご意見ございましたら、お気軽にご連絡ください

Metadata

ID: docker-best-practices/avoid-add-use-copy

Language: Docker

Severity: Info

Category: Best Practices

Description

This rule encourages the use of COPY instead of ADD in Dockerfiles when simply copying files or directories. While both instructions can copy files into the image, ADD has additional functionality such as extracting local tar archives and fetching remote URLs.

To make your Dockerfiles more uniform and predictable, you should use COPY unless you need ADD’s extra functionality.

See official Docker documentation

Non-Compliant Code Examples

FROM python:3.4
ADD requirements.txt /usr/src/app/

Compliant Code Examples

FROM python:3.4
COPY requirements.txt /usr/src/app/
ADD https://example.com/file.go /src
ADD archive.tar.gz /src/archive
ADD [email protected]:user/repo.git /src/foorepo
https://static.datadoghq.com/static/images/logos/github_avatar.svg https://static.datadoghq.com/static/images/logos/vscode_avatar.svg jetbrains

シームレスな統合。 Datadog Code Security をお試しください