17
12

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 3 years have passed since last update.

UbuntuベースのDockerでタイムゾーンを設定する

Last updated at Posted at 2018-12-28

Ubuntuイメージのタイムゾーンを日本に変更します。

FROM ubuntu:16.04

# Shift timezone to Asia/Tokyo.
RUN apt-get update && apt install -y tzdata && apt-get clean && rm -rf /var/lib/apt/lists/*
ENV TZ Asia/Tokyo

JSTに変更されました

$ docker build . -t ubuntu-tz
$ docker run -it ubuntu-tz /bin/bash
root@a73c2ad58201:/# date
Fri Dec 28 17:17:09 JST 2018

ついでにロケールも日本語(UTF-8)に設定すると日本語環境で問題の無いイメージになると思います。

FROM ubuntu:16.04

# Shift timezone to Asia/Tokyo.
RUN apt-get update && apt-get install -y tzdata && apt-get clean && rm -rf /var/lib/apt/lists/*
ENV TZ Asia/Tokyo

# Set local to jp.
RUN apt-get update && apt-get install -y language-pack-ja && \
    update-locale LANG=ja_JP.UTF-8 && rm -rf /var/lib/apt/lists/*
ENV LANG ja_JP.UTF-8
ENV LANGUAGE ja_JP:ja
ENV LC_ALL ja_JP.UTF-8
$ docker build . -t ubuntu-tz-locale
$ docker run -it ubuntu-tz-locale /bin/bash
root@77ee4d90670a:/# date
2018年 12月 28日 金曜日 17:22:46 JST
17
12
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
17
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?