5
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Dockerコンテナのtimezone

Last updated at Posted at 2015-05-28

アパッチのログがお昼ぐらいにも関わらず、午前3時とかになってる・・・

/var/log/httpd/error_log
      :
[Thu May 28 03:29:56 2015] [error] ....
      :

変だなと思って調べてみると・・・
UTCになってる。

$ date
Thu May 28 03:54:52 UTC 2015

今までOSインストールすると日本語を選ぶので、こうなっている状況は初めて、変更方法をググるとある設定ファイルをコピーするといいらしい。
あれ?「-f」をつけているにも関わらずoverwriteの確認。
手動の場合はいいけど、Dockerでビルドするときまずくない?

# cp -f /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
cp: overwrite `/etc/localtime'? y

これもなんでこうなるのか・・・どうやらAliasっぽい・・・

# alias
alias cp='cp -i'
      :

コマンドでたたく場合は「\cp」とするか「/bin/cp」とすればいい。

デフォルトの設定を変えるかunaliasでもいいとは思うけど、それも面倒なのでDockerfileの中はこうしておけばいいということですね・・・

Dockerfile
      :
RUN /bin/cp -f /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
      :

これでapacheのログも日本時間。

5
7
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
5
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?