Das Hinzufügen von „export utf8“ zu /etc/profile funktioniert nicht

Das Hinzufügen von „export utf8“ zu /etc/profile funktioniert nicht

Ich versuche, das Gebietsschema in debian:stretch auf utf8 einzustellen. Ich erstelle ein Docker-Image, das ich dann verwende. Auszug aus meinem Dockerfile:

# Set locale
RUN 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

Gitlab-Job, der das von mir erstellte Image verwendet:

$ 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=

Ich verstehe nicht, warum es nicht geändert wird. Es scheint, als würde die /etc/profileDatei nicht gelesen.

Antwort1

So zitieren Sie die bash(1)Handbuchseite:

Wenn bash als interaktive Login-Shell oder als nicht-interaktive Shell mit der --loginOption aufgerufen wird, liest und führt es zuerst Befehle aus der Datei aus /etc/profile, sofern diese Datei vorhanden ist.
Nach dem Lesen dieser Datei sucht es in dieser Reihenfolge nach ~/.bash_profile, ~/.bash_login, und und ~/.profileliest und führt Befehle aus der ersten Datei aus, die vorhanden und lesbar ist. Die --noprofileOption kann beim Starten der Shell verwendet werden, um dieses Verhalten zu unterbinden.

<…>

Wenn eine interaktive Shell gestartet wird, die keine Login-Shell ist, liest und führt Bash Befehle aus /etc/bash.bashrc und aus ~/.bashrc, wenn diese Dateien vorhanden sind. Dies kann durch die Verwendung der --norcOption verhindert werden. Die --rcfileOption „file“ zwingt Bash, Befehle aus der Datei statt aus /etc/bash.bashrcund zu lesen und auszuführen ~/.bashrc.

verwandte Informationen