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.
- Meaning of
rpm --import / etc / pki / rpm-gpg / RPM-GPG-KEY-CentOS-7
The signature of the rpm package. Required to verify the integrity of the rpm package. If you don’t do this,yum update
may give you the following warnings:
However, it is not always necessary to write it because it will perform the same operation as above when an error occurs. This is done so that you will not be surprised by unnecessary errors.
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
- Meaning of
yum clean all
Clear the cache generated byyum update
. As shown below, the image size is completely different depending on whether you doyum clean all
or not. The only difference between the two is whether or not you have doneyum clean all
.
In this article, I attached it toyum update
, but the lastyum update
andyum install
It doesn’t make sense until after that, so I think it’s okay if you put it near the end of theRUN
command so that maintenance is less likely to be required.
$ 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
- I made a docker container for CentOS7 that supports Japanese in Window10
It also explains how to translateman
into Japanese.