Docker Community Forums

Share and learn in the Docker community.

Change Language inside container

Hi @all

I have a problem which I am not able to solve and hope that someone can help me out.

I created a docker image with a complete ubuntu-mate (with gui that can be accessed via X2GO-Client).

When I build the image for ubuntu:16.04 everything works fine.
Although I can not change the language via the gui-setting (Add Language), I can successfully change the language via “sudo dpkg-reconfigure locales”. After re-login, all changed to the new language (in my case it is german).

When I build the same Dockerfile with 18:04 or 20.04, the build is fine, but when I change the language via “sudo dpkg-reconfigure locales” only the OS itself is in german, but NOT the application(s). The applications (kmymoney, gimp, libreoffice,…) are in english.

I also must say that when I build the image for ubuntu:16.04 and then inside the container I do a “do-release-upgrade” it also works fine (all the applications have the correct languages) - But building directly for 18.04 or 20.04 does not change the language for the applications.

Maybe you have a quick solution for me - If you are experienced you maybe know what to exactly how to change the language inside the container.
If not, I can provide the Dockerfile if needed

Thx in advance for your help

Those settings are shell-session bound, not OS-bound. To make it OS-bound, you should write it in OS files, but when the service restarts it will apply the image without those changes.

So, that has to be set in Dockerfile, to be image-bound, something like:

RUN DEBIAN_FRONTEND=noninteractive apt-get install -y locales &&
sed -i -e ‘s/# pt_PT ISO-8859-1/pt_PT ISO-8859-1/’ /etc/locale.gen &&
dpkg-reconfigure --frontend=noninteractive locales
ENV LANG pt_PT
ENV LANGUAGE pt_PT
ENV LC_ALL pt_PT

Thx for the reply :grinning:
I will try it out.
In the meanwhile I have a “workaround”
I created my own image from the squashfs of the ubuntu-mate.iso.
I uploaded my base image and I used my own image ramirezfx/mate:latest instead of ubuntu:latest
This works fine for me - But I will definitively give it a try.

Thx

Once again lewish95 the Let me Google that for you bot has committed plagiarism. (ref)