如何在 Debian/Ubuntu Docker 容器中设置语言环境? [英] How to set the locale inside a Debian/Ubuntu Docker container?

查看:45
本文介绍了如何在 Debian/Ubuntu Docker 容器中设置语言环境?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行一个 Ubuntu Docker 容器.我有挪威语键盘,需要使用挪威语字符 (øæå).

I'm running a Ubuntu Docker container. I have a Norwegian keyboard and need to use Norwegian characters (øæå).

我的终端字符编码设置为 UTF-8,我使用 SSH 连接到我的容器.但是,我无法输入挪威语字符,无法复制和粘贴挪威语字符,也无法使用 CTL+SHIFT+U+00f8.

My Terminal character encoding is set to UTF-8 and I'm connected to my container using SSH. However, I'm unable to type Norwegian characters, nor copy and paste Norwegian characters, nor use CTL+SHIFT+U+00f8.

我试过了:

locale-gen nb_NO.UTF-8

但没有任何改变.如何在 Docker 容器内设置语言环境和键盘?

but nothing changed. How do I set the locale and keyboard inside a Docker container?

推荐答案

在你的 Dockerfile 中放入一些改编自

Put in your Dockerfile something adapted from

# Set the locale
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && 
    locale-gen
ENV LANG en_US.UTF-8  
ENV LANGUAGE en_US:en  
ENV LC_ALL en_US.UTF-8     

如果您运行 Debian 或 Ubuntu,您还需要安装 locales 以拥有 locale-gen

If you run Debian or Ubuntu, you also need to install locales to have locale-gen with

apt-get -y install locales

这是从关于该主题的非常好的帖子中提取的,来自

this is extracted from the very good post on that subject, from

http://jaredmarkell.com/docker-and-locales/

这篇关于如何在 Debian/Ubuntu Docker 容器中设置语言环境?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆