I'm running a Ubuntu Docker container. I have a Norwegian keyboard and need to use Norwegian characters (øæå).
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.
I tried:
locale-gen nb_NO.UTF-8
but nothing changed. How do I set the locale and keyboard inside a Docker container?
Those who use Debian also have to install
locales
package.This answer helped me a lot.
Put in your Dockerfile something adapted from
this is extracted from the very good post on that subject, from
http://jaredmarkell.com/docker-and-locales/
Just add
into your Dockerfile. Nothing else is needed for the basic operation. Meanwhile,
locale-gen
doesn’t accept any arguments, that’s why none of the ‘fixes’ using it work.I dislike having Docker environment variables when I do not expect user of a Docker image to change them. I think the following is much cleaner:
(Edit: This does not work. It seems I tested it badly initially.)
Just put it somewhere in one
RUN
. If you do not have UTF-8 locales generated, then you can do the following set of commands:I actually happened to have suffered from the same problem, but none of the provided answers are 100% working with debian:latest, even if they provide good hints.
The biggest difference is that you should make sure both locales and locales-all are installed, the latter already containing en_US.UTF-8, so you don't have to generate it with local-gen or dpkg-reconfigure.
Here's what I've done in my Dockerfile to make it work:
Specify these environment variables when running your command:
It's not necessary to modify the Dockerfile.