Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change locale settings on Fedora Docker container?

Tags:

docker

fedora

On a normal server e.g. a Linode VPS I would normally do:

localectl set-locale LANG=<locale>.utf8
timedatectl set-timezone <timezone>

But since systemd is not present or does not work on containers I get:

Failed to create bus connection: No such file or directory

Now, my goal is just to change these settings without using systemd but such approach seems to go undocumented. Is there a reference for non-systemd alternatives to config tools?

like image 269
arielnmz Avatar asked Nov 07 '22 09:11

arielnmz


1 Answers

Some documentation about locale setting in arch wiki: https://wiki.archlinux.org/index.php/locale

In Dockerfile, adjust LANG to your desired locale. You can add more than one locale in /etc/locale.gen to have a choice later.

Works on debian, arch, but locale-gen misses on fedora:

ENV LANG=en_US.utf8
RUN echo "$LANG UTF-8" >> /etc/locale.gen
RUN locale-gen
RUN update-locale --reset LANG=$LANG

More general is localedef, works on fedora, too:

ENV LANG=en_US.UTF-8
localedef --verbose --force -i en_US -f UTF-8 en_US.UTF-8
like image 190
mviereck Avatar answered Nov 14 '22 21:11

mviereck