なぜか突然Dockerfileをbuildする時にtzdataでタイムゾーンの選択を求められるようになりました。
以前はこんなエラー出なかったはずなのに…
Dockerfile
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
GitHubではこのコードを実行すると何やらインストールできるらしいことが書いてあったので実行してみました。
RUN apt-get update && apt-get install -y --no-install-recommends apt-utils
しかし、結果はNG
参考にしているものが古かったのでバージョンを上げたら解決するかな?と思ってUbuntuのバージョンを18.04にしてみたけどダメ…
Gitのインストールが原因??
こちらの記事を読んでいるとGitのパッケージインストール後にtzdataをインストールするとのこと。
試しにgit と tzdata のインストールする順番を変えてみる
Dockerfile
RUN DEBIAN_FRONTEND=noninteractive #入力を求められずにインストールするための呪い
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y \
tzdata \# ←gitより前に持ってくる
git \
あれ…?効果なし
気を取り直してgit と tzdate のRUNを分けてインストールすると…
Dockerfile
RUN DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y tzdata
# timezone setting
ENV TZ=Asia/Tokyo
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y \
tzdata \
無事インストールできました!
タイムゾーンも日本(JST)になっていることが確認できました。
root@b8dfdd02ae92:/# date
Tue Jul 31 22:18:18 JST 2018
“
標準時(イギリス)にでも住んでいない限りタイムゾーンの設定は必要なのでDockerを利用するときの参考にしてみてください!
コメントを残す