모든 사용자에 대해 Dockerfile의 debian Stretch에서 로캘 설정

모든 사용자에 대해 Dockerfile의 debian Stretch에서 로캘 설정
RUN apt-get update && \
    # Install locales
    apt-get install -y locales && \
    # Set locale
    sed --in-place '/en_US.UTF-8/s/^# //' /etc/locale.gen && \
    locale-gen && \
    # Set system locale (add line)
    echo "export LANG=en_US.UTF-8" >> /etc/profile && \
    # Set system timezone (add line)
    echo "export TZ=UTC" >> /etc/profile && \
    # If the user will not change, we must source
    source /etc/profile

내 GitLab 파이프라인에서 이미지를 사용하면 다음이 표시됩니다.

$ cat /etc/profile
# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).

if [ "`id -u`" -eq 0 ]; then
  PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
else
  PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games"
fi
export PATH

if [ "${PS1-}" ]; then
  if [ "${BASH-}" ] && [ "$BASH" != "/bin/sh" ]; then
    # The file bash.bashrc already sets the default PS1.
    # PS1='\h:\w\$ '
    if [ -f /etc/bash.bashrc ]; then
      . /etc/bash.bashrc
    fi
  else
    if [ "`id -u`" -eq 0 ]; then
      PS1='# '
    else
      PS1='$ '
    fi
  fi
fi

if [ -d /etc/profile.d ]; then
  for i in /etc/profile.d/*.sh; do
    if [ -r $i ]; then
      . $i
    fi
  done
  unset i
fi
export LANG=en_US.UTF-8
export TZ=UTC
$ locale
LANG=
LANGUAGE=
LC_CTYPE="POSIX"
LC_NUMERIC="POSIX"
LC_TIME="POSIX"
LC_COLLATE="POSIX"
LC_MONETARY="POSIX"
LC_MESSAGES="POSIX"
LC_PAPER="POSIX"
LC_NAME="POSIX"
LC_ADDRESS="POSIX"
LC_TELEPHONE="POSIX"
LC_MEASUREMENT="POSIX"
LC_IDENTIFICATION="POSIX"
LC_ALL=

누군가 데비안에서 로케일이 실제로 어떻게 작동하는지 설명할 수 있다면. Ubuntu에 대해서만 다른 답변을 읽었습니다. https://stackoverflow.com/questions/28405902/how-to-set-the-locale-inside-a-docker-container http://jaredmarkell.com/docker-and-locales/

답변1

거기에 설명되어 있습니다 :http://jaredmarkell.com/docker-and-locales/

이 사이트와 귀하의 링크에 따르면 로케일은 다음 지시문에 의해 Dockerfile에 정의됩니다.

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  

우분투는 데비안 파생물에만 있으며 도커 통합은 두 배포판 모두와 매우 유사합니다.

또한 sed를 첫 번째 파일로 처리하십시오. 주석 처리를 제거하면 됩니다(공백 제거는 필수가 아닙니다).

sed --in-place '/en_US.UTF-8/s/^#//'

답변2

로케일을 설치하지 않으면 "apt install locales-all"이 필요합니다. 로케일을 설치하지 않으면 "LC_ALL을 기본 로케일로 설정할 수 없습니다. 해당 파일이나 디렉터리가 없습니다"가 표시됩니다.

관련 정보