LoginSignup
23
13

More than 5 years have passed since last update.

Alpine Linux で timezone を変更する(最新版?)

Last updated at Posted at 2018-04-24

alpine ベースの Docker イメージを使うと標準では UTC になる
ログの時間を localtime で取りたくなったのでメモ

Dockerfile に以下の命令を加える
/etc/localtime の設定だけではうまく行かないことがあったので /etc/timezone も変更すると良いかも

RUN apk add --update --no-cache tzdata && \
    cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime && \
    echo "Asia/Tokyo" > /etc/timezone && \
    apk del tzdata

apk は Alpine Linux のパッケージマネージャ
--no-cache オプションをつけておけばアンインストール後にキャッシュを削除する必要がなくなる

基本的なことだが
全て1回の RUN に詰め込むことで無駄なレイヤーを作らずに済むのがポイント

参考:http://wiki.alpinelinux.org/wiki/Setting_the_timezone

23
13
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
23
13