CentOS / sig-cloud-instance-images

CentOS cloud images
781 stars 564 forks source link

Locale set to en_US.UTF-8, but only C.UTF-8 installed in centos:8 #154

Open Enchufa2 opened 5 years ago

Enchufa2 commented 5 years ago

Related to #71 and #58. Steps to reproduce:

$ docker run -it centos:8 bash
$ locale
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_ALL to default locale: No such file or directory
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

but

$ ls /usr/lib/locale/
C.utf8

I think that the locale should be set to C.UTF-8 by default, as it is in Fedora.

naivetoby commented 5 years ago

yum install -y glibc-langpack-en

Enchufa2 commented 5 years ago

I know, but having to do that it's kind of annoying. Language settings should be properly configured by default (by setting C.UTF-8 or by having that package installed by default; I'd prefer the first option, as fedora and centos:7 do).

emeti commented 5 years ago

I think as Enchufa2 - it should default better. In CentOS 7 default locale was set to POSIX and all was fine, no error messages all over the place.

billtian commented 4 years ago

there are some Docker images based on CentOS (like jenkins/jenkins:centos) can not display file path correctly even added the --env LANG=en_US.UTF-8 running parameter.

karthiksonti24 commented 4 years ago

You can use these commands to set it up . yum install -y glibc-locale-source localedef --no-archive -i en_US -f UTF-8 en_US.UTF-8 export LANG=en_US.UTF-8

qhaas commented 4 years ago

Noticed this the other day, glad I wasn't the only person that thought it was odd.

I agree with @Enchufa2 , the locale should default to something that is deployed inside the image by default (e.g. 'C.utf8' or just 'POSIX').

qhaas commented 3 years ago

Still exists in the 8.3 release

qhaas commented 3 years ago

Looks like the official RH UBI8 images use only POSIX and C.utf8

$ podman run --rm registry.access.redhat.com/ubi8/ubi-minimal:8.4 /bin/bash -c locale | grep NAME
LC_NAME="POSIX"
$ podman run --rm registry.access.redhat.com/ubi8/ubi-minimal:8.4 /bin/bash -lc locale | grep NAME
LC_NAME="C.utf8"
fweimer-rh commented 3 years ago

In the current image, the locale is configured as en_US.UTF-8, presumably via this file:

# cat /etc/locale.conf
LANG="en_US.UTF-8"

I think this file should be dropped, and the locale such be set from the container file instead, so that it can be changed easily from the outside. As far as I can tell podman run does not implement locale forwarding (unlike SSH in CentOS), so this change should be sufficient to address the issue.

qhaas commented 3 years ago

Still exists in the newly posted 8.4 images (thanks for upgrading, btw):

$ podman run --rm docker.io/centos:8 cat /etc/redhat-release
CentOS Linux release 8.4.2105
$ podman run --rm docker.io/centos:8 cat /etc/locale.conf
LANG="en_US.UTF-8"
$ podman run --rm docker.io/centos:8 /bin/bash -c locale | grep NAME
LC_NAME="POSIX"
$ podman run --rm docker.io/centos:8 /bin/bash -lc locale | grep NAME
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_ALL to default locale: No such file or directory
LC_NAME="en_US.UTF-8"
qhaas commented 2 years ago

Would this fix (upstream) be as simple as changing this line from lang en_US to lang C.utf8?

fweimer-rh commented 2 years ago

There's more locale setup further below. It seems that a later step (that is not reflected in the kickstart file) removes en_US.UTF-8 from the image. Maybe that should be removed and the installation changed to use C.UTF-8.

qhaas commented 2 years ago

There's more locale setup further below. It seems that a later step (that is not reflected in the kickstart file) removes en_US.UTF-8 from the image. Maybe that should be removed and the installation changed to use C.UTF-8.

Bet that will do the trick, was going to test and hopefully get in a merge request, but ran into an unexpected Not enough free space on selected disks per Issue 176 when trying to build the stock image (on a system with plenty of free HDD space).

qhaas commented 2 years ago

Given CentOS 8 is dead, long live CentOS Stream 8, the latter's container appears to not have the locale issue, guessing this issue is now OBE?

$ podman run --rm centos:stream8 cat /etc/redhat-release
CentOS Stream release 8
$ podman run --rm centos:stream8 cat /etc/locale.conf
LANG=C.utf8
$ podman run --rm centos:stream8 /bin/bash -c locale | grep NAME
LC_NAME="POSIX"
$ podman run --rm centos:stream8 /bin/bash -lc locale | grep NAME
LC_NAME="C.utf8"