Skip to content

Add more locales to the Postgres images or describe in the docs how to add a particular locale

By default, the current Docker container contains only the following locales:

C
C.UTF-8
en_US.utf8
POSIX

If you are trying to connect to a database that was created with a different locale:

FATAL:  database locale is incompatible with operating system
DETAIL:  The database was initialized with LC_COLLATE "ru_RU.UTF-8",  which is not recognized by setlocale().
HINT:  Recreate the database with another locale or install the missing locale.
Previous connection kept

To be able to create clones with a database with a locale other than the default en_US.UTF-8
Consider installing the locales-all package. This package contains the precompiled locale data for all supported locales.

RUN apt-get install -y locales locales-all

Another alternative is to generate only the required locales using locale-gen.
Example for ru_RU.UTF-8:

RUN apt-get install -y locales && sed -i '/ru_RU.UTF-8/s/^# //g' /etc/locale.gen && locale-gen
Edited by Vitaliy Kukharik