[lxc-users] color in console not working in unprivileged containers
Michael H. Warfield
mhw at WittsEnd.com
Sun Mar 22 03:26:44 UTC 2015
On Sun, 2015-03-22 at 12:54 +1000, Mark Constable wrote:
> On 22/03/15 02:12, Michael H. Warfield wrote:
> > 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
>
> Wonderful thorough explanation, thanks Mike.
>
> FWIW it's also possible to do something like this too (not documented in
> the man pages from lxd-daily/vivid (1.1.0-0ubuntu1))...
> lxc-attach -n mycontainer -v TERM=linux
That will work with lxc-attach. It will not work with lxc-console. The
reason is that lxc-console attaches to one of the console ttys in the
container which then goes through the getty (agetty) waiting on that tty
for initial setup. The man pages for (a)getty are very explicit that
getty will override any existing TERM variable.
OTOH, lxc-attach will attach directly to a shell without running through
getty, and avoid that problem. It also inherits the TERM variable from
the calling process, so you get "xterm-256color" in the case with
lxc-attach where you don't specify the TERM type or "linux" if you
specify it the way you describe above. I don't see any advantage of
"linux" over "xterm-256color" one way or the other. Downside with
lxc-attach is that you don't have any controlling tty, which can have
other adverse problems, like job control.
For some reason, it appears that "vt102" is compiled into the version of
getty on Ubuntu as default while "linux" is compiled into the version of
getty on Fedora as default. The man pages also make clear that this
version of getty does not reference /etc/gettydefs. :-P Getty is the
culprit and I don't see any other workaround for lxc-console. That same
change may need to be made in /etc/init/console.conf but I don't quite
see where it's coming into play.
That change may need to be integrated into the Ubuntu (and probably
Debian) templates.
Regards,
Mike
> and --clear-env seems to remove host env vars and without a .bashrc or
> .profile there is not even a TERM var and sure enough there are no colors
> in a ls listing (oic, "set" shows a TERM=dumb)...
>
> ~ lxc-attach -n v1 --clear-env
> root at v1:/root# env
> PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
> PWD=/root
> SHLVL=1
> container=lxc
> _=/usr/bin/env
>
> And also FWIW these are my 2 favorite aliases of late...
>
> alias a='lxc-attach --clear-env -v USER=root -v HOME=/root -v TERM=linux -v LANG=en_US.UTF-8 -v LC_ALL=en_US.UTF-8 -n'
>
> alias lx='lxc-ls -f'
>
> _______________________________________________
> 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/c583f574/attachment.sig>
More information about the lxc-users
mailing list