[Lxc-users] Confusing behaviour using LXC container with systemd

Serge Hallyn serge.hallyn at ubuntu.com
Tue Mar 12 22:25:51 UTC 2013


Quoting John (lxc at jelmail.com):
> Hello, I've been trying to convert some containers to systemd. I have 
> implemented a systemd container using lxc.autodev with lxc.hook.autodev 
> to create additional devices and I can now start containers that run 
> systemd internally. I am, however, experiencing some problems and am at 
> a loss as to how I should troubleshoot.
> 
> My autodev hook contains the below:
> 
> #!/bin/bash
> # LXC Autodev hook.
> cd ${LXC_ROOTFS_MOUNT}
> mknod -m 600 .//dev/tty0 c 4 0
> mknod -m 666 .//dev/ptmx c 5 2
> 
> The first problem is that starting a container affects devices on the 
> host. I don't know how widespread the problem is but I noticed it 

Presumably this is just because your guest is running 'udevadm trigger'.
We disable that in ubuntu using apparmor, but if you allow it then the
guest triggers the host into resetting hardware.  Sound card goes back
to default level, keyboard gets reset, ...

...

> The second problem might be related... If I start a systemd container 
> from a gui terminal window, the window starts pumping out characters 
> (normally "=" symbols but this changes if I type on the keyboard, though 
> not to the character typed). If I move the focus to another terminal 
> window the character output moves with the focus. This happens if I 
> start the container with  "lxc-start" or with "systemctl". It does not 
> happen if I start the container on a text virtual terminal (Alt+F1). (in 
> case it's relevant, the gui is itself inside a container that is still 
> init-based).

Sounds like systemd is playing with /dev in the container.  You say
you're using autodev hooks, but (a) what is the actual filesystem in
the container's /dev?  If it's devtmpfs then it's shared with your
host, and your container is actually corrupting your host's /dev and
(b) otherwise systemd may simply be re-creating things like /dev/console
and /dev/tty after you've set them up in your autodev hook.

Oh!  or systemd is mounting the host's /dev/pts into the container.

-serge




More information about the lxc-users mailing list