2016-09-29 86 views
42

我把區域設置下面的代碼到我dockerfile,搬運工Ubuntu的/ bin/sh的:1:現場根:沒有發現

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 

任何理念?

+7

也許你必須使用'sudo apt-get -y install locales'來安裝'locales'? – edwinksl

回答

76

感謝您的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 
+16

爲了提高效率,您需要避免使用多個'RUN'語句,特別是當這些語句緊密相關時。像'RUN apt-get clean && apt-get -y update && apt-get install -y locales && locale-gen en_US.UTF-8'會創建一個單層而不是三個。 – tripleee

+1

也許'update-locale LC_ALL = en_US.UTF-8 LANG = en_US.UTF-8'也很有用https://askubuntu.com/a/505424/196423 – koppor