Japanese localization of Docker container of CentOS7 / CentOS8 and Japan time setting

Conclusion

If you build the following Dockerfile, you can create a container with Japanese language and Japanese time zone.

〇 CentOS7

FROM centos:7
RUN rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 && \
    yum -y update && \
    yum clean all && \
    localedef -f UTF-8 -i ja_JP ja_JP.UTF-8 && \
    ln -sf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
ENV LANG="ja_JP UTF-8" \
    LANGUAGE="ja_JP:ja" \
    LC_ALL="ja_JP.UTF-8" \
    TZ="Asia/Tokyo"

〇 CentOS8

FROM centos:8
RUN rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial && \
    dnf -y upgrade && \
    dnf -y install glibc-locale-source && \
    dnf clean all && \
    localedef -f UTF-8 -i ja_JP ja_JP.UTF-8 && \
    ln -sf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
ENV LANG="ja_JP UTF-8" \
    LANGUAGE="ja_JP:ja" \
    LC_ALL="ja_JP.UTF-8" \
    TZ="Asia/Tokyo"

environment

How to use / check

Build the container image in the directory where the above Docker file is located. After that, set up the container and check that the Japanese localization and time zone setting are reflected in date.

〇CentOS7

$ docker build -t centos:7-ja .
$ docker run -dit --name centos7-ja centos:7-ja
$ docker exec centos7-ja date
Saturday, September 26, 2020 19:37:24 JST

〇CentOS8

$ docker build -t centos:8-ja .
$ docker run -dit --name centos8-ja centos:8-ja
$ docker exec centos8-ja date
Saturday, September 26, 2020 19:42:03 JST

Digression

I made it because I wanted to understand the settings required for Japanese localization. The following is a memo of what I learned while working.

warning: /var/cache/yum/x86_64/7/updates/packages/bind-license-9.11.4-16.P2.el7_8.6.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
$ docker images
REPOSITORY          TAG                  IMAGE ID            CREATED             SIZE
centos              7-ja-without-clean   3f6ba3d02f45        5 minutes ago       352MB
centos              7-ja-with-clean      fa93ef373ec3        6 minutes ago       284MB

reference

Recommended Posts

Japanese localization of Docker container of CentOS7 / CentOS8 and Japan time setting
Japanese localization of CentOS 8 and Japanese keyboard layout
Japanese setting of mysql in Docker container
Summary of Japan time setting and display method
Japanese localization of Ubuntu20.04
Japanese localization of Eclipse
Overview of Docker and containers
Japanese localization of error messages
[Japanese localization of gem: devise]
[Introduction] Installation of Docker Desktop for Mac for the first time and setup of virtual environment construction of CentOS
[Rails] Japanese localization of error messages
[Rails] Validation settings and Japanese localization
Japanese localization of error messages (rails)
About Docker, disguise server and container
STS installation and Japanese localization on Windows 10
Kind @ Mac in Docker and vctl container
Explanation of Ruby Time and Date objects
[Challenge Docker from 0] Overview and terms of Docker
Introduction of Docker Hub and commands Self-learning ①
How to build a Jenkins server with a Docker container on CentOS 7 of VirtualBox and access the Jenkins server from a local PC