Re: [lxc-users] How to set LXD container locale?

2016-03-19 Thread zztest

On 2016-03-19 10:16, Stéphane Graber wrote:

On Sat, Mar 19, 2016 at 03:33:11AM -0700, zzt...@openmailbox.org wrote:

None of the typical ways of setting locales seem to stick in my Ubuntu
container in an Ubuntu host (Ubuntu 15.10, LXD 2.0.0.rc4)

The host's locale shows this

LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=


but the container shows this


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"

/etc/default/locale contains the same value (LANG="en_US.UTF-8") in 
both the
container and the host, but I cannot get it to set in the container. 
How is

the locale set/changed in an LXD container?

Thanks.


Note that if you're using "lxc exec", LXD only executes the shell that
you asked for, it doesn't setup a PAM session for you, so you start 
with

an empty environment.

One way to solve that is to do a "su root" which will then send you
through the PAM stack (if your container has one) which will then 
source

any needed environment.

Another way if you don't want to go through PAM, is to set environment
variables directly on the container or one of its profiles, like:

lxc config set CONTAINER environment.LC_ALL=en_US.UTF-8

LXD will then set those environment variables for you every time you
exec a command inside the container.

___
lxc-users mailing list
lxc-users@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-users


Thanks Stéphane. "su " works. What's the difference between that 
and "lxc exec CONTAINER -- /bin/bash"?  And is there another way to 
enter the container without using "lxc exec" that will setup PAM (or at 
least do it automatically)?


___
lxc-users mailing list
lxc-users@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-users

Re: [lxc-users] How to set LXD container locale?

2016-03-19 Thread Stéphane Graber
On Sat, Mar 19, 2016 at 03:33:11AM -0700, zzt...@openmailbox.org wrote:
> None of the typical ways of setting locales seem to stick in my Ubuntu
> container in an Ubuntu host (Ubuntu 15.10, LXD 2.0.0.rc4)
> 
> The host's locale shows this
> 
> LANG=en_US.UTF-8
> LANGUAGE=
> LC_CTYPE="en_US.UTF-8"
> LC_NUMERIC="en_US.UTF-8"
> LC_TIME="en_US.UTF-8"
> LC_COLLATE="en_US.UTF-8"
> LC_MONETARY="en_US.UTF-8"
> LC_MESSAGES="en_US.UTF-8"
> LC_PAPER="en_US.UTF-8"
> LC_NAME="en_US.UTF-8"
> LC_ADDRESS="en_US.UTF-8"
> LC_TELEPHONE="en_US.UTF-8"
> LC_MEASUREMENT="en_US.UTF-8"
> LC_IDENTIFICATION="en_US.UTF-8"
> LC_ALL=
> 
> 
> but the container shows this
> 
> 
> 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"
> 
> /etc/default/locale contains the same value (LANG="en_US.UTF-8") in both the
> container and the host, but I cannot get it to set in the container. How is
> the locale set/changed in an LXD container?
> 
> Thanks.

Note that if you're using "lxc exec", LXD only executes the shell that
you asked for, it doesn't setup a PAM session for you, so you start with
an empty environment.

One way to solve that is to do a "su root" which will then send you
through the PAM stack (if your container has one) which will then source
any needed environment.

Another way if you don't want to go through PAM, is to set environment
variables directly on the container or one of its profiles, like:

lxc config set CONTAINER environment.LC_ALL=en_US.UTF-8

LXD will then set those environment variables for you every time you
exec a command inside the container.

-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com


signature.asc
Description: PGP signature
___
lxc-users mailing list
lxc-users@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-users

Re: [lxc-users] How to set LXD container locale?

2016-03-19 Thread Claudio Kuenzler
Have you tried this way:

echo "en_US.UTF-8 UTF-8" > /etc/locale.gen

locale-gen

It's the method we're using the set the locale in LXC containers.

On Sat, Mar 19, 2016 at 11:33 AM,  wrote:

> None of the typical ways of setting locales seem to stick in my Ubuntu
> container in an Ubuntu host (Ubuntu 15.10, LXD 2.0.0.rc4)
>
> The host's locale shows this
>
> LANG=en_US.UTF-8
> LANGUAGE=
> LC_CTYPE="en_US.UTF-8"
> LC_NUMERIC="en_US.UTF-8"
> LC_TIME="en_US.UTF-8"
> LC_COLLATE="en_US.UTF-8"
> LC_MONETARY="en_US.UTF-8"
> LC_MESSAGES="en_US.UTF-8"
> LC_PAPER="en_US.UTF-8"
> LC_NAME="en_US.UTF-8"
> LC_ADDRESS="en_US.UTF-8"
> LC_TELEPHONE="en_US.UTF-8"
> LC_MEASUREMENT="en_US.UTF-8"
> LC_IDENTIFICATION="en_US.UTF-8"
> LC_ALL=
>
>
> but the container shows this
>
>
> 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"
>
> /etc/default/locale contains the same value (LANG="en_US.UTF-8") in both
> the container and the host, but I cannot get it to set in the container.
> How is the locale set/changed in an LXD container?
>
> Thanks.
>
>
> ___
> lxc-users mailing list
> lxc-users@lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-users
___
lxc-users mailing list
lxc-users@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-users

[lxc-users] How to set LXD container locale?

2016-03-19 Thread zztest
None of the typical ways of setting locales seem to stick in my Ubuntu 
container in an Ubuntu host (Ubuntu 15.10, LXD 2.0.0.rc4)


The host's locale shows this

LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=


but the container shows this


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"

/etc/default/locale contains the same value (LANG="en_US.UTF-8") in both 
the container and the host, but I cannot get it to set in the container. 
How is the locale set/changed in an LXD container?


Thanks.


___
lxc-users mailing list
lxc-users@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-users