Problem
You want to install some default locales in a Docker image, and the suggestion is to use locale-gen to do so, but it does not work as expected.
Solution
In order to be able to use the locale-gen and install the locales you need you will have to uncomment the ones needed from /etc/locale.gen first and then use the locale-gen. Example below:
## Set up locales ## Uncomment the ones we need as locale-gen does not work without that RUN sed -i '/en_US.UTF-8/s/^#//' /etc/locale.gen RUN sed -i '/de_DE.UTF-8/s/^#//' /etc/locale.gen ## Now install them and set the default one RUN locale-gen ENV LANG en_US.UTF-8 ENV LANGUAGE en_US:en ENV LC_ALL en_US.UTF-8