7

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?

4 Answers 4

3

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 
Sign up to request clarification or add additional context in comments.

Comments

-1

Put this in your Dockerfile

ENV TZ=America/Denver RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone 

Comments

-2

Edit .bash_profile or .bashrc from root and add the following.

TZ='Asia/Kolkata' export TZ 

Save file and commit image after its done.

1 Comment

There is no need to that as you can set ENV=Asia/Kolkata in the Dockerfile.
-2

Based on a technique used in sti-base, I came up with the following workaround for https://github.com/ncoghlan/fedbuildenv/blob/09a18d91e7af64a45394669bac2595a4b628960d/Dockerfile#L26:

# Set a useful default locale RUN echo "export LANG=en_US.utf-8" > /opt/export_LANG.sh ENV BASH_ENV=/opt/export_LANG.sh \ ENV=/opt/export_LANG.sh \ PROMPT_COMMAND="source /opt/export_LANG.sh" 

BASH_ENV covers non-interactive bash sessions, ENV covers sh sessions, and PROMPT_COMMAND covers interactive bash sessions.

this seems to be the debians's equivalent of locale-gen:

RUN localedef -v -c -i fr_FR -f UTF-8 fr_FR.UTF-8 || true 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.