When working with CentOS 7 Docker containers, you might encounter situations where certain locale packages aren't included in the base image. This becomes particularly problematic when you need to set up Japanese language support for applications or system messages.
First, let's check what locale packages are currently installed:
# locale -a
# yum list installed | grep langpack
The proper way to install Japanese support in CentOS 7 involves installing specific packages rather than using the non-existent "Japanese Support" group:
# yum install -y langpacks-ja glibc-common
# localedef -v -c -i ja_JP -f UTF-8 ja_JP.UTF-8
After installation, configure your system to use Japanese locale:
# echo "LANG=ja_JP.UTF-8" > /etc/locale.conf
# source /etc/locale.conf
For reproducible builds, include these commands in your Dockerfile:
FROM centos:7
RUN yum install -y langpacks-ja glibc-common && \
localedef -v -c -i ja_JP -f UTF-8 ja_JP.UTF-8 && \
echo "LANG=ja_JP.UTF-8" > /etc/locale.conf
ENV LANG ja_JP.UTF-8
After building your container, verify the Japanese locale is properly installed:
# locale -a | grep ja_JP
# date +%x (should display date in Japanese format)
If you're using a minimal CentOS image, you might need additional packages:
# yum install -y langpacks-ja glibc-locale-source glibc-langpack-ja
If you encounter errors during installation, try updating your package database first:
# yum clean all
# yum makecache
When working with CentOS 7 minimal Docker images, you'll quickly notice they don't include comprehensive language support out of the box. The default installation only includes basic English locales, which becomes problematic when you need to:
- Process Japanese text data
- Display correct character encoding
- Run applications expecting Japanese locale settings
First, check what locales are currently available in your container:
# Check installed locales
locale -a
# View current locale settings
locale
The proper approach involves installing the langpacks-ja
package rather than looking for a non-existent group:
# Install required packages
yum install -y glibc-common langpacks-ja
# Generate Japanese locales
localedef -c -f UTF-8 -i ja_JP ja_JP.utf8
# Verify the new locale is available
locale -a | grep ja_JP
For permanent changes, modify the locale configuration:
# Set system-wide locale (edit /etc/locale.conf)
echo "LANG=ja_JP.UTF-8" > /etc/locale.conf
# Alternative: Set for current session only
export LANG=ja_JP.UTF-8
Create a test file to verify everything works:
# Create test file with Japanese text
echo "日本語テスト" > japanese_test.txt
# Display the file
cat japanese_test.txt
# Check character encoding
file -i japanese_test.txt
For reproducible builds, include this in your Dockerfile:
FROM centos:7
RUN yum install -y glibc-common langpacks-ja && \
localedef -c -f UTF-8 -i ja_JP ja_JP.utf8 && \
echo "LANG=ja_JP.UTF-8" > /etc/locale.conf
ENV LANG ja_JP.UTF-8
If you encounter problems:
- Ensure
glibc-common
is installed (required for locale generation) - Verify the container has enough disk space for locale data
- Check that your terminal/SSH client supports UTF-8 encoding