PostgreSQL Docker to German LANG

Hi how can I change the docker postgrsql so that it can work in the german region?
In the docker itself its discribed:

You can extend the image with a simple Dockerfile to set a different locale. The following example will set the default locale to de_DE.utf8 :

FROM postgres:9.4
RUN localedef -i de_DE -c -f UTF-8 -A /usr/share/locale/locale.alias de_DE.UTF-8
ENV LANG de_DE.utf8

But that I do not understand how I can add this? Env Lang i know how to change it but the other is not clear for me :frowning:
Can anyone help me?

What exactly is the issue?

The default local in the postgres container is set to eng_US.utf8:

me@swarm1:~$ docker exec -ti $(docker ps --filter name=kc_postgres -q) locale
LANG=en_US.utf8
LANGUAGE=
LC_CTYPE=“en_US.utf8”
LC_NUMERIC=“en_US.utf8”
LC_TIME=“en_US.utf8”
LC_COLLATE=“en_US.utf8”
LC_MONETARY=“en_US.utf8”
LC_MESSAGES=“en_US.utf8”
LC_PAPER=“en_US.utf8”
LC_NAME=“en_US.utf8”
LC_ADDRESS=“en_US.utf8”
LC_TELEPHONE=“en_US.utf8”
LC_MEASUREMENT=“en_US.utf8”
LC_IDENTIFICATION=“en_US.utf8”
LC_ALL=

I guess your problem is more related to formating like the thousend and decimal delimiter than special characeters?

This should get you up and running.

FROM postgres:9.4 
RUN sed -i 's/^# *\(en_US.UTF-8\|de_DE.UTF-8\)/\1/' /etc/locale.gen && \
        locale-gen
ENV LANG de_DE.utf8

I did build the image with the tag postgres_de. The result looks like what you need:

me@swarm1:~/postgres$ docker run -ti --rm postgres_de locale
LANG=de_DE.utf8
LANGUAGE=
LC_CTYPE=“de_DE.utf8”
LC_NUMERIC=“de_DE.utf8”
LC_TIME=“de_DE.utf8”
LC_COLLATE=“de_DE.utf8”
LC_MONETARY=“de_DE.utf8”
LC_MESSAGES=“de_DE.utf8”
LC_PAPER=“de_DE.utf8”
LC_NAME=“de_DE.utf8”
LC_ADDRESS=“de_DE.utf8”
LC_TELEPHONE=“de_DE.utf8”
LC_MEASUREMENT=“de_DE.utf8”
LC_IDENTIFICATION=“de_DE.utf8”
LC_ALL=

I do not know how to built the image with the tag postgres_de

Don’t worry the tag itself had no effect on the solution. A tag is like a bookmark for an image.

The solution is in the RUN block of my post. I used docker build -t postgres_de . to build the image, where -t is the tag. Though, you should use a tag more suited to your situation.

but ist postges_de a file with the content:
FROM postgres:9.4
RUN localedef -i de_DE -c -f UTF-8 -A /usr/share/locale/locale.alias de_DE.UTF-8
ENV LANG de_DE.utf8

?

I find your post confusing.

I wrote that the solution is in the RUN block of my post, so obviously I did use my RUN declaration and not yours.

sudo docker run -ti --rm postgres_de locale
Password:
Unable to find image ‘postgres_de:latest’ locally
docker: Error response from daemon: pull access denied for postgres_de, repository does not exist or may require ‘docker login’.
See ‘docker run --help’

You need to use the content of the Dockerfile I posted and build your own image.
I just named my LOCAL BUILD posgres_de.

Please past the content in your Dockerfile and build it:

FROM postgres:9.4 
RUN sed -i 's/^# *\(en_US.UTF-8\|de_DE.UTF-8\)/\1/' /etc/locale.gen && \
        locale-gen
ENV LANG de_DE.utf8

The trick is to uncomment the locals and let the os generate them. After they have been generated, they can be used.

Bitte den Inhalt exakt übernehmen. So wie es dort steht funktioniert es und erlaubt im Nachgang die Nutzung von de_DE.ut8.

sorry, I used docker on my synology dsm, so thats a bit different

The UI just restricts functions and the swarm mode is messed up, appart from that it is a “real” docker engine.

thanks I did the docker build like in your example that was ok :slight_smile: but when I want to change the postgresql.conf to the correct parameter it does not start
LOG: invalid value for parameter “lc_messages”: “de_DE.utf8”
LOG: invalid value for parameter “lc_monetary”: “de_DE.utf8”
LOG: invalid value for parameter “lc_numeric”: “de_DE.utf8”
LOG: invalid value for parameter “lc_time”: “de_DE.utf8”
FATAL: configuration file “/var/lib/postgresql/data/postgresql.conf” contains errors

when setting the e settings in docker to LANG de_DE.utf8 the container stoped and I get this error:
initdb: invalid locale settings; check LANG and LC_* environment variables

Hi,

I am also stucked with this German issue, now got the answer,