「WARNING: apt does not have a stable CLI interface. Use with caution in scripts.」の警告が表示された

ショコラ
ショコラ

「WARNING: apt does not have a stable CLI interface. Use with caution in scripts.」の警告が表示された

(翻訳)「警告:aptには安定したCLIインターフェースがありません。スクリプトでは注意して使用してください。」→ただの警告なので無視で大丈夫ですけど、代わりに「apt-get」を使うでキメマス。

もっさん先輩
もっさん先輩
apt-get install -y {パッケージ名}
apt-get install -y --no-install-recommends {パッケージ名}

パッケージのインストール後に以下のコマンドを実行すると、インストール時に使った不要なファイルを削除して、コンテナイメージを小さくすることができます。

apt-get clean
rm -rf /var/lib/apt/lists/*

シチュエーション

スクリプトの中で apt install を行ったところ警告が表示された。

$ docker build .
Sending build context to Docker daemon  5.632kB
Step 1/3 : FROM php:apache
 ---> 3a812e010be3
Step 2/3 : RUN apt update
 ---> Using cache
 ---> cab740b9e942
Step 3/3 : RUN apt install -y --no-install-recommends vim
 ---> Running in 4cfa81f27221

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
Scroll to Top