1

I have set following locale settings in my Dockerfile:

# Set the russian locale
RUN apt-get clean && apt-get update && apt-get install -y locales
RUN locale-gen ru_RU.UTF-8
ENV LANG ru_RU.UTF-8
ENV LANGUAGE ru_RU.UTF-8
ENV LC_ALL ru_RU.UTF-8

It seems that locale does not set correctly:

root@4fcfdd39679c:/front-office# locale 
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=ru_RU.UTF-8
LANGUAGE=ru_RU.UTF-8
LC_CTYPE="ru_RU.UTF-8"
LC_NUMERIC="ru_RU.UTF-8"
LC_TIME="ru_RU.UTF-8"
LC_COLLATE="ru_RU.UTF-8"
LC_MONETARY="ru_RU.UTF-8"
LC_MESSAGES="ru_RU.UTF-8"
LC_PAPER="ru_RU.UTF-8"
LC_NAME="ru_RU.UTF-8"
LC_ADDRESS="ru_RU.UTF-8"
LC_TELEPHONE="ru_RU.UTF-8"
LC_MEASUREMENT="ru_RU.UTF-8"
LC_IDENTIFICATION="ru_RU.UTF-8"
LC_ALL=ru_RU.UTF-8
root@4fcfdd39679c:/front-office#

but when i write text in bash (running like this: docker-compose run --rm app bash), there is malformed cyrillic text - it starts with char ":�" and not fully supported all russian letters. How to solve it?

Aleks Boev
  • 630
  • 1
  • 7
  • 16
  • 1
    Note: this error is often not on the image, but on the terminal which should show the text. Do you have a good font? The locale on the viewing computer is set correctly? And the TERM? – Giacomo Catenazzi Feb 26 '19 at 15:15
  • I`m not sure. How I can check the font and TERM? – Aleks Boev Feb 27 '19 at 08:09
  • 1
    Where you run docker. For me the problem is on your "computer" side (not inside docker). Check that your terminal support Unicode and that TERM environmanr variable (also inside docker) is compatible with the setting of your terminal. – Giacomo Catenazzi Feb 27 '19 at 08:29

1 Answers1

3

I added follow code to Dockerfile and rebuilded image. All works well

RUN apt-get update && apt-get install -y locales

# Locale
RUN sed -i -e \
  's/# ru_RU.UTF-8 UTF-8/ru_RU.UTF-8 UTF-8/' /etc/locale.gen \
   && locale-gen

ENV LANG ru_RU.UTF-8
ENV LANGUAGE ru_RU:ru
ENV LC_LANG ru_RU.UTF-8
ENV LC_ALL ru_RU.UTF-8

Link to original answer on StackOverflow.ru

Aleks Boev
  • 630
  • 1
  • 7
  • 16