[lxc-users] color in console not working in unprivileged containers

Michael H. Warfield mhw at WittsEnd.com
Sat Mar 21 16:12:56 UTC 2015


On Sat, 2015-03-21 at 11:46 +0100, david.andel at bli.uzh.ch wrote:
> The colors also work when logging in with ssh.
> Only with lxc-console they do not work.

The problem is not with lxc-console.  It's the getty configuration in
the Ubuntu container.

Try this...

Check the value of your TERM environment variable.  After logging in
using lxc-console type this:

set | grep TERM

(Yes, you can also do "echo ${TERM}" but I like using grep to show the
variable name for this purpose.)

If I do that on one of my Fedora containers I get:

[mhw at Fedora20 ~]$ set | grep TERM
TERM=linux

Color works in that container from lxc-console.

On one of my Ubuntu containers (on the same host), I get this:

mhw at Ubuntu-14:~$ set | grep TERM
TERM=vt102

Color doesn't work in that container from lxc-console and I wouldn't
expect it to.  The vt102 TERM type doesn't support color.

Now type this in that container:

export TERM=linux

Now do an ls.

Hey, how about that...  Color now works in lxc-console.

And just confirming...

mhw at Ubuntu-14:~$ echo ${TERM}
linux

Now, if I ssh into either of those containers I see this:

mhw at Ubuntu-14:~$ echo ${TERM}
xterm-256color

And color works...  But that value for TERM is passed to it from the ssh
client through the sshd server.

To fix the problem permanently, do the following in the container:

Edit the files /etc/init/tty* and find the lines that say this (for
tty1.conf for example):

exec /sbin/getty -8 38400 tty1

Append "linux" to the end of those lines in each file so it reads like
this (for tty1.conf)

exec /sbin/getty -8 38400 tty1 linux

You'll then need to restart the getty service or restart the container.

Regards,
Mike

> -----"lxc-users" <lxc-users-bounces at lists.linuxcontainers.org> wrote:
> -----
> To: LXC users mailing-list <lxc-users at lists.linuxcontainers.org>
> From: david.andel at bli.uzh.ch
> Sent by: "lxc-users" 
> Date: 03/20/2015 20:30
> Subject: Re: [lxc-users] color in console not working in unprivileged
> containers
> 
> Thanks Xavier,
> unfortunately, this is not the issue.
> The colors work out of the box when I access the container using
> lxc-attach, but they do not work when I access the container using
> lxc-console - not even using --color=auto.
> And I see the same behavior on two independent systems (both running
> utopic with the same lxc version).
> 
> David
> 
> -----"lxc-users" <lxc-users-bounces at lists.linuxcontainers.org> wrote:
> -----
> To: lxc-users at lists.linuxcontainers.org
> From: Xavier Gendre 
> Sent by: "lxc-users" 
> Date: 03/19/2015 1:35
> Subject: Re: [lxc-users] color in console not working in unprivileged
> containers
> 
> Maybe, this is because the colors are simply not enabled... Try 'ls 
> --color=auto' in your container. If the colors are back, then tweak
> your 
> .bashrc to enable them permanently.
> 
> Xavier
> 
> Le 18/03/2015 22:30, david.andel at bli.uzh.ch a écrit :
> > Hi,
> > in unprivileged containers color in the console does not work out of
> the
> > box.
> > How can it be enabled?
> >
> > I am running ubuntu utopic with lxc 1.1.0~alpha2-0ubuntu3.2.
> >
> > Thanks,
> > David
> >
> >
> > _______________________________________________
> > lxc-users mailing list
> > lxc-users at lists.linuxcontainers.org
> > http://lists.linuxcontainers.org/listinfo/lxc-users
> >
> _______________________________________________
> lxc-users mailing list
> lxc-users at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-users
> 
> _______________________________________________
> lxc-users mailing list
> lxc-users at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-users
> 
> _______________________________________________
> lxc-users mailing list
> lxc-users at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-users

-- 
Michael H. Warfield (AI4NB) | (770) 978-7061 |  mhw at WittsEnd.com
   /\/\|=mhw=|\/\/          | (678) 463-0932 |  http://www.wittsend.com/mhw/
   NIC whois: MHW9          | An optimist believes we live in the best of all
 PGP Key: 0x674627FF        | possible worlds.  A pessimist is sure of it!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 465 bytes
Desc: This is a digitally signed message part
URL: <http://lists.linuxcontainers.org/pipermail/lxc-users/attachments/20150321/2689e67f/attachment.sig>


More information about the lxc-users mailing list