无法在 Docker 镜像中配置区域设置

问题描述 投票:0回答:2

我正在尝试在我的 Docker 映像中安装语言环境文件,但由于某种原因它没有正确安装。

我的

Dockerfile
中的这些行配置+安装语言环境文件:

# Install and configure locales
RUN ["apt-get", "install", "-y", "locales"]
RUN ["locale-gen", "nl_NL.UTF-8"]
RUN ["dpkg-reconfigure", "locales"]
RUN ["update-locale"]
ENV LANG nl_NL.UTF-8

镜像创建成功。当我运行

docker exec **ID** locale -a
时,我仍然得到以下错误:

locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_COLLATE to default locale: No such file or directory
C
C.UTF-8
POSIX

所以我猜它没有正确安装语言环境文件。任何人都可以帮助我吗?

ubuntu docker locale ubuntu-14.04 dockerfile
2个回答
5
投票

同时尝试

locales
locales-all

喜欢:

RUN apt-get update && apt-get install -y --no-install-recommends \
    locales \
    locales-all \

0
投票

有点晚了,但我希望这对其他人有帮助。有类似的问题,以下命令对我有用

# syntax=docker/dockerfile:1
FROM ubuntu:22.04


# Set the locale
RUN apt-get update && apt-get install -y locales \
    locales-all 
RUN locale-gen nl_NL.UTF-8  
ENV LANG nl_NL.UTF-8  
ENV LANGUAGE nl_NL:nl 
ENV LC_ALL nl_NL.UTF-8  
RUN update-locale LANG=nl_NL.UTF-8
© www.soinside.com 2019 - 2024. All rights reserved.