NVIDIA の CUDA 対応した Ubuntu 20.04 のイメージから Docker イメージをビルドしようとすると、zdata のタイムゾーン入力を求められてしまいました。そのため、手動入力が発生せずに自動でビルドできるようにします。
Dockerfile の記述
Docker ファイルには下記のように記述していました。
FROM nvidia/cuda:11.4.1-devel-ubuntu20.04
RUN sed -i 's@archive.ubuntu.com@www.ftp.ne.jp/Linux/packages/ubuntu/archive@g' /etc/apt/sources.list
RUN apt-get update && \
apt-get install -y --no-install-recommends tzdata
ENV TZ=Asia/Tokyo
これをビルドしようとすると、途中でタイムゾーンの入力を求められます。結果として自動でビルドされません。
...
Step 4/20 : RUN apt-get update && apt-get install -y --no-install-recommends tzdata
...
Fetched 19.1 MB in 39s (484 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
The following NEW packages will be installed:
tzdata
0 upgraded, 1 newly installed, 0 to remove and 6 not upgraded.
Need to get 295 kB of archives.
After this operation, 4033 kB of additional disk space will be used.
Get:1 http://ftp-srv2.kddilabs.jp/Linux/packages/ubuntu/archive/ubuntu focal-updates/main amd64 tzdata all 2021a-0ubuntu0.20.04 [295 kB]
debconf: delaying package configuration, since apt-utils is not installed
Fetched 295 kB in 1s (204 kB/s)
Selecting previously unselected package tzdata.
(Reading database ... 12753 files and directories currently installed.)
Preparing to unpack .../tzdata_2021a-0ubuntu0.20.04_all.deb ...
Unpacking tzdata (2021a-0ubuntu0.20.04) ...
Setting up tzdata (2021a-0ubuntu0.20.04) ...
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
Configuring tzdata
------------------
Please select the geographic area in which you live. Subsequent configuration
questions will narrow this down by presenting a list of cities, representing
the time zones in which they are located.
1. Africa 4. Australia 7. Atlantic 10. Pacific 13. Etc
2. America 5. Arctic 8. Europe 11. SystemV
3. Antarctica 6. Asia 9. Indian 12. US
Geographic area:
Dockerfile の記述修正
環境変数 DEBIAN_FRONTEND を noninteractive に設定します。具体的には下記の通りとしました。
FROM nvidia/cuda:11.4.1-devel-ubuntu20.04
ENV DEBIAN_FRONTEND noninteractive
RUN sed -i 's@archive.ubuntu.com@www.ftp.ne.jp/Linux/packages/ubuntu/archive@g' /etc/apt/sources.list
RUN apt-get update && \
apt-get install -y --no-install-recommends tzdata
ENV TZ=Asia/Tokyo
これでタイムゾーンの入力を求められることはなくなりました。
注意点
しかし、Docker の公式ドキュメントにおいては、DEBIAN_FRONTEND を noninteractive に設定することは止めたほうがよいと言及されています。よって、個々の事情であったり、この設定がされたイメージが他者にも使用される可能性などを考慮した上で設定の可否を検討するのがよいだろうと考えます。