This product is not supported for your selected Datadog site. ().
Cette page n'est pas encore disponible en français, sa traduction est en cours.
Si vous avez des questions ou des retours sur notre projet de traduction actuel, n'hésitez pas à nous contacter.

Metadata

ID: docker-best-practices/yarn-clean

Language: Docker

Severity: Warning

Category: Best Practices

Description

This rule ensures that after running yarn install in a Dockerfile, a yarn cache clean command is executed to remove unnecessary cache files. This practice helps to minimize the image size by cleaning up temporary files and caches that are not needed for the runtime environment. mes.

To comply with this rule, always chain yarn install with yarn cache clean in the same RUN instruction like RUN yarn install && yarn cache clean. This approach ensures that the cache cleanup happens immediately after installation, reducing the number of layers and keeping the image optimized.

Non-Compliant Code Examples

RUN yarn install

Compliant Code Examples

RUN yarn install \
 && yarn cache clean
https://static.datadoghq.com/static/images/logos/github_avatar.svg https://static.datadoghq.com/static/images/logos/vscode_avatar.svg jetbrains