Este producto no es compatible con el sitio Datadog seleccionado. ().
Esta página aún no está disponible en español. Estamos trabajando en su traducción.
Si tienes alguna pregunta o comentario sobre nuestro actual proyecto de traducción, no dudes en ponerte en contacto con nosotros.

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, which can introduce unexpected behavior.

Using COPY is preferred because it is more explicit and predictable, reducing the risk of unintended side effects that could occur with ADD. This leads to clearer, more maintainable Dockerfiles and helps avoid security issues related to downloading remote files during the build process.

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/
https://static.datadoghq.com/static/images/logos/github_avatar.svg https://static.datadoghq.com/static/images/logos/vscode_avatar.svg jetbrains

Integraciones sin problemas. Prueba Datadog Code Security