How to add language support on CentOS 7 (on Docker)?

49,162

Solution 1

I had the same problem with a RHEL 7.4 docker image. yum reinstall glibc-common by itself didn't resolve the problem. It was only installing English.

I found in my docker container /etc/yum.conf contained the line override_install_langs=en_US. This caused yum reinstall glibc-common to only install English.

With this line commented out (or changed to the default value of all), and re-running yum reinstall glibc-common I was able to use other languages

Initial Environment after docker run/attach

# locale -a
C
POSIX
en_US.utf8
# grep lang /etc/yum.conf
override_install_langs=en_US
# export LANG=fr_FR
# ls foo
ls: cannot access foo: No such file or directory

My attempt at reinstalling glib-common before changing /etc/yum.conf

# yum -y -q reinstall glibc-common
Failed to set locale, defaulting to C
# ls foo
ls: cannot access foo: No such file or directory
# locale -a
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_COLLATE to default locale: No such file or directory
C
POSIX
en_US
en_US.iso88591
en_US.iso885915
en_US.utf8
#

After changing /etc/yum.conf to comment out the line override_install_langs=en_US

# vi /etc/yum.conf
# grep lang /etc/yum.conf
#override_install_langs=en_US
# yum -y -q reinstall glibc-common
Failed to set locale, defaulting to C
# ls foo
ls: cannot access foo: Aucun fichier ou dossier de ce type
# locale -a | wc -l
789

Solution 2

You need to reinstall the glibc-common package. Here is the proof:

docker run -it --rm centos bash -c 'locale -a | wc -l && yum -y -q reinstall glibc-common && locale -a | wc -l'
53
789

Note: locale -a lists installed locales, and wc -l counts them, so those numbers are the number of locales before and after reinstalling glibc-common.

Share:
49,162
DIGITALSQUAD
Author by

DIGITALSQUAD

Updated on September 18, 2022

Comments

  • DIGITALSQUAD
    DIGITALSQUAD over 1 year

    I'm trying to set locale to Japanese, but CentOS image on docker doesn't include language support.

    bash-4.2# yum groupinstall -y "Japanese Support"
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
     * base: mirrors.btte.net
     * extras: centos.mirror.secureax.com
     * updates: centos.mirror.secureax.com
    Warning: group Japanese Support does not exist.
    Maybe run: yum groups mark install (see man yum)
    No packages in any requested group available to install or update
    

    I've checked grouplist by yum grouplist and yum grouplist hidden and neither include Japanese Support.
    Is there any way to install Japanese Support?
    Thanks in advance.