LoginSignup
0
1

More than 3 years have passed since last update.

Dockerでapt-get upgrade

Last updated at Posted at 2020-05-28

はじめに

Dockerでイメージをビルドしようとすると、ユーザインタラクションを避ける必要があります。ところがapt-get upgrade したときのサービスのリスタートの確認では、一般につかわれている -y オプションをつけてもYes/Noの確認がでてしまいdocker build が停止してしまいます。

問題点

Dockerfile内でapt-upgradeすると、-yをつけようが--force-yesをつけようが--allow-downgradesをつけようが--allow-remove-essentialをつけようが--allow-change-held-packages をつけようが、以下のプロンプトが避けられない

Configuring libssl1.1:arm64
There are services installed on your system which need to be restarted when
certain libraries, such as libpam, libc, and libssl, are upgraded. Since these
restarts may cause interruptions of service for the system, you will normally
be prompted on each upgrade for the list of services you wish to restart.  You
can choose this option to avoid being prompted; instead, all necessary restarts
will be done for you automatically so you can avoid being asked questions on
each library upgrade.

Restart services during package upgrades without asking? [yes/no]

で、これがでるとdocker build がとまって、どうしようもない感じ

解決策

debconf-set-selections
コマンドに設定をいれることでプロンプトのデフォルトの選択肢が選択できます。
'* libraries/restart-without-asking boolean true'をわたすことで、上記のプロンプトでとまるのを抑止できました。
Dockerfileに以下を設定

RUN echo '* libraries/restart-without-asking boolean true' |  
debconf-set-selections

でもって、このあとの
apt-get upgrade -y
では上記のプロンプトでは止まらなくなります。

利用例

Darknetをビルド済なXavierNX/JetsonNANOのDockerイメージを作成でつくったイメージだと、apt-upgradeがおこなわれなくて、いろいろ起きますが、これで、apt-get updateとupgrade部分を自動化することができます。

FROM darknet:100
RUN apt-get -y update
RUN echo '* libraries/restart-without-asking boolean true' |  debconf-set-selections
RUN apt-get -y upgrade
RUN apt -y install xfce4-terminal
CMD ["/bin/bash"]
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1