Always pin versions in apt-get install

이 페이지는 아직 한국어로 제공되지 않으며 번역 작업 중입니다. 번역에 관한 질문이나 의견이 있으시면 언제든지 저희에게 연락해 주십시오.

Metadata

ID: docker-best-practices/apt-pin-version

Language: Docker

Severity: Notice

Category: Best Practices

Description

When using apt-get install, pin the version to avoid unwanted upgrades and undefined behavior.

Non-Compliant Code Examples

FROM debian:12

RUN set -eux; \
    apt-get update; \
    apt-get install -y curl git gcc g++ make cmake; \
    rm -rf /var/cache/apt/archives /var/lib/apt/lists/*
FROM debian:12
RUN apt-get install python

RUN apt-get update && \
    apt-get install -y --no-install-recommends openjdk-19-jdk && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/ /var/cache/oracle*

Compliant Code Examples

FROM debian:12
RUN apt-get install python=3.11
https://static.datadoghq.com/static/images/logos/github_avatar.svg https://static.datadoghq.com/static/images/logos/vscode_avatar.svg jetbrains

Seamless integrations. Try Datadog Code Analysis