kasei_sanのブログ

かせいさんのIT系のおぼえがきです。胡乱の方はnoteとtwitterへ

Dockerfileで apt-get upgrade するのは止めたほうが良いとベストプラクティスに書かれていた

Dockerfile best practices によると...

Avoid RUN apt-get upgrade and dist-upgrade, as many of the “essential” packages from the parent images cannot upgrade inside an unprivileged container. If a package contained in the parent image is out-of-date, contact its maintainers. If you know there is a particular package, foo, that needs to be updated, use apt-get install -y foo to update automatically.

docs.docker.com

雑な翻訳

親イメージの「必須」パッケージの多くは、権限のないコンテナ内ではアップグレードできないため、apt-get upgrade や dist-upgrade の実行は避けてください。親イメージに含まれるパッケージが古い場合は、そのメンテナに連絡してください。更新が必要なパッケージ foo があることがわかっている場合は、apt-get install -y foo を使って自動的に更新してください。

親イメージが必須とするパッケージ、foo を更新したい場合、自前で apt-get upgrade せずに、メンテナに連絡した上で apt-get install foo で個別にインストールすべきとのこと

ついでに apt-get upgradeapt-get update の違い

  • apt-get update: パッケージリストの更新
  • apt-get upgrade: インストール済みのパッケージ更新