在Dockerfile

时间:2018-03-15 12:01:17

标签: ubuntu docker debian

我试图涵盖在Dockerfile中设置区域设置和时区的所有情况。我写了以下内容,但感觉有点矫枉过正:

# Set for current session
ENV LC_ALL="en_US.UTF-8" \
    LANG="en_US.UTF-8" \
    LANGUAGE="en_US.UTF-8" \
    TZ="UTC"

# Install locales
    # Uncomment en_US.UTF-8 locales in /etc/locale.gen file
RUN sed --in-place '/en_US.UTF-8/s/^# //' /etc/locale.gen && \
    # Generate new locales from /etc/locale.gen file
    locale-gen && \
    # Set system locale for login shells
    echo "export LC_ALL=en_US.UTF-8" >> /etc/profile && \
    echo "export LANG=en_US.UTF-8" >> /etc/profile && \
    echo "export LANGUAGE=en_US.UTF-8" >> /etc/profile && \
    # Set system timezone for login shells
    echo "export TZ=UTC" >> /etc/profile && \
    # Set system locale for non-login shells for root
    echo "export LC_ALL=en_US.UTF-8" >> ~/.bashrc && \
    echo "export LANG=en_US.UTF-8" >> ~/.bashrc && \
    echo "export LANGUAGE=en_US.UTF-8" >> ~/.bashrc && \
    # Set system timezone for non-login shells for root
    echo "export TZ=UTC" >> ~/.bashrc

如你所见,我试图覆盖(对于bash ofc):

  • 当前会议
  • 所有用户的登录shell
  • 所有用户的非登录shell

以上是否过度杀伤?不正确的?有没有更合适的方式来涵盖所有案件?

0 个答案:

没有答案