docker ubuntu /bin/sh: 1: locale-gen: not found

UbuntuDocker

Ubuntu Problem Overview


I put the locale setting codes below into my dockerfile,

FROM node:4-onbuild

# Set the locale
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8

but it gives me the error

/bin/sh: 1: locale-gen: not found
The command '/bin/sh -c locale-gen en_US.UTF-8' returned a non-zero code: 127

any idea?

Ubuntu Solutions


Solution 1 - Ubuntu

Thanks for your comment, edwinksl. I updated my dockerfile below which solved the locale-gen error:

FROM node:4-onbuild

# Set the locale
RUN apt-get clean && apt-get update && apt-get install -y locales
RUN locale-gen en_US.UTF-8

Solution 2 - Ubuntu

apt-get install -y locales
localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8

localedef is also good to use.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionHammerView Question on Stackoverflow
Solution 1 - UbuntuHammerView Answer on Stackoverflow
Solution 2 - UbuntuIzanaView Answer on Stackoverflow