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
Ich verwende das Bild in meiner GitLab-Pipeline und Folgendes wird angezeigt:
$ 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=
Wenn mir jemand erklären könnte, wie das Gebietsschema in Debian tatsächlich funktioniert. Ich habe andere Antworten nur für Ubuntu gelesen: https://stackoverflow.com/questions/28405902/wie-man-das-Gebietsschema-inside-a-docker-container-einstellt http://jaredmarkell.com/docker-and-locales/
Antwort1
Dort erklärt:http://jaredmarkell.com/docker-and-locales/
Laut dieser Site und Ihren Links werden die Gebietsschemas in den Docker-Dateien durch diese Anweisungen definiert:
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
Ubuntu ist das einzige Debian-Derivat und die Docker-Integration ist in beiden Distributionen recht ähnlich.
Achten Sie auch auf sed in der ersten Datei, Sie müssen nur die Kommentare entfernen (das Entfernen des Leerzeichens ist nicht zwingend erforderlich).
sed --in-place '/en_US.UTF-8/s/^#//'
Antwort2
"apt install locales-all" ist erforderlich. Andernfalls wird bei install locales-all die Meldung "LC_ALL kann nicht auf Standardgebietsschema eingestellt werden: Keine solche Datei oder kein solches Verzeichnis" angezeigt.