【问题标题】:docker ubuntu /bin/sh: 1: locale-gen: not founddocker ubuntu /bin/sh: 1: locale-gen: 未找到
【发布时间】:2017-02-07 05:03:09
【问题描述】:

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

有什么想法吗?

【问题讨论】:

  • 也许您必须使用sudo apt-get -y install locales 安装locales

标签: ubuntu docker


【解决方案1】:

感谢your comment, 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

【讨论】:

  • 为了提高效率,您需要避免使用多个RUN 语句,尤其是当它们像这样密切相关时。像RUN apt-get clean && apt-get -y update && apt-get install -y locales && locale-gen en_US.UTF-8 这样的东西会创建一个单层而不是三层。
  • 也许update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8也有用askubuntu.com/a/505424/196423
  • 为了保持理智,您需要避免将所有命令集中在一个 RUN 中
【解决方案2】:
apt-get install -y locales
localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8

localedef 也很好用。

【讨论】:

  • 这应该是公认的答案,它是本页所有答案中正确设置 perl 语言环境的唯一方法!
猜你喜欢
  • 1970-01-01
  • 2017-10-20
  • 2021-07-24
  • 1970-01-01
  • 1970-01-01
  • 2019-05-15
  • 1970-01-01
  • 2018-04-26
  • 2017-03-08
相关资源
最近更新 更多