linuxdockerdockerfilelocale

"update-locale: Error: invalid locale settings" when using a Dockerfile


I'm getting an error when trying to install and set a custom locale in docker :

INFO[0040] cmd: /bin/sh                                 
INFO[0040] args: [-c update-locale LANG=fr_FR.UTF-8]    
INFO[0040] Running: [/bin/sh -c update-locale LANG=fr_FR.UTF-8] 
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = "fr_FR:fr",
    LC_ALL = "fr_FR.UTF-8",
    LANG = "fr_FR.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
*** update-locale: Error: invalid locale settings:  LANG=fr_FR.UTF-8
error building image: error building stage: failed to execute command: waiting for process to exit: exit status 255

Here is a snippet of my Dockerfile :

WORKDIR /app

RUN apt-get update && apt-get install -y \
    build-essential \
    curl \
    software-properties-common \
    git \
    locales \
    && rm -rf /var/lib/apt/lists/*

RUN locale-gen fr_FR.UTF-8

ENV LANG=fr_FR.UTF-8
ENV LANGUAGE=fr_FR:fr
ENV LC_ALL=fr_FR.UTF-8

RUN update-locale LANG=fr_FR.UTF-8

COPY . .

RUN pip3 install -r requirements.txt

Do you guys know how to solve this problem ? For your info, I don't have access to the docker terminal.


Solution

  • What I do in this case:

    sed -i -E 's/^# (fr_FR.UTF-8.*)/\1/' /etc/locale.gen
    locale-gen