I'm trying to set up my Linux machine to run multiple guest OSes, one of those being a Windows VM, and another a Linux container. The goal here is to prevent me from messing up the host system, while being free to operate the base operating system and play with the host hardware. Eventually, on top of running my desktop in the container, I hope to run graphics-accelerated simulations, etc. Since Docker has such nice git-like versioning of containers built-in, it seemed like a good idea to use it. Perhaps libvirt would do just as good with LXC, but docker's privileged mode makes it easier to not have to configure devices to the container.
I've done a little research and come up with a few answers already, but I'm having trouble putting it all together.
Background in LXC
Running X from LXC helped me to see how I can configure a container with (i.e.):
lxc.cgroup.devices.allow = c 226:0 rwm
mknod -m 666 dri/card0 c 226 0
inside the container to connect to the host device.
From cuda - Using GPU from a docker container, I saw that I can get the same setup to work in Docker with the LXC backend.
It appeared to me that if a docker container is run in privileged mode, then it can access the GPU normally without this extra configuration. So, I fired up a base system, installed graphics drivers, xorg-server, xorg-xinit, and a window manager to test it out.
# startx Cannot run from a console (or some message like that)
Okay, I thought I was on tty2.
# tty /dev/console
That's not what I expected.
# chvt 2 # tty /dev/tty2
Well, it appears as if that worked. Let's try
# startx again. It started the window manager, with the cursor in the center. No mouse response. No keyboard response. Let's try to change the tty with
Ctrl-Alt+F3. No response. Well, it looks like I'll have to reboot cold.
# tty /dev/console # chvt 2 # tty /dev/console
What? I can't change it now?
After trying another time, I got it to change tty, and startx froze the computer again.
So, I'm now at an impass. I really want to be able to use a container - Docker preferred, LXC with libvirt is also acceptable - to run as my daily operating system while keeping a lean host OS.
Is it best to use Docker with privileged mode here, or to use the explicit LXC backend and try the options listed above?
I am already planning on using libvirt (possibly under vagrant-libvirt) to manage my Windows vm, so would it be about the same for me to use libvirt or vagrant-LXC in this case?
Edit: reading LXC vs. Docker, I get the feeling that since Docker and Docker containers are meant for single-application environments, perhaps it would be best to use LXC instead of Docker to run as my daily operating system. Thoughts?
Edit: I've discovered that, like docker, there is a lxc-device command which allows me to bypass the cgroups and mknod steps. Whereas before I was able to get x to start and freeze my system, it just errors out now. Perhaps I can figure this out eventually, since no one seems to be out there.
Update: I have the mouse working. On the guest, I installed xf86-input-mouse and xf86-input-keyboard. On the host, I ran the following:
# lxc-device -n g1 add /dev/input/mice # lxc-device -n g1 add /dev/dri/card0 # lxc-device -n g1 add /dev/dri/controlD64 # lxc-device -n g1 add /dev/dri/renderD128 # lxc-device -n g1 add /dev/fb0 # lxc-device -n g1 add /dev/tty2