docker ubuntu / bin / sh:1:locale-gen:找不到


95

我将下面的语言环境设置代码放入了我的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

但这给了我错误

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

任何想法?


13
也许您必须locales使用安装sudo apt-get -y install locales
edwinksl 16/09/29

Answers:


188

谢谢您的评论,edwinksl。我更新了下面的dockerfile,解决了locale-gen错误:

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

26
为了提高效率,您需要避免使用多个RUN语句,尤其是当它们之间紧密相关时。类似的东西RUN apt-get clean && apt-get -y update && apt-get install -y locales && locale-gen en_US.UTF-8将创建一个单层而不是三层。
Tripleee '17

8
也许update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8也是有用的askubuntu.com/a/505424/196423
koppor
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.