Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

is it currently possible to setup LXC containers with X11 capabilities? I'm looking forward for the lightest available X11 container (memory-wise), hardware acceleration a plus but not essential.

If it is not currently possible, or readily available, is it known what functionality needs to be yet implemented in order to support it?

share|improve this question

1 Answer 1

up vote 7 down vote accepted

yes it is possible to run a complete X11 desktop environment inside a LXC container.

Right now, I do this on Arch Linux. I won't say it's "light" as I haven't gone as far as trying to strip out stuff from the standard package manager install but I can confirm that it does work very well.

You have to install any kernel drivers on the HOST as well as in the container. Such things as the graphics driver (I use nvidia). You have to make the device nodes in dev accessible inside the container by configuring your container.conf to allow it. You then need to make sure that those device nodes are created inside the container (i.e mknod).

So, to answer you question: YES it does work. If I can help any further or provide more details please do let me know.

--- additional infomation provided ---

In my container... /etc/inittab starts in run level 5 and launches "slim" Slim is configured to use vt09:

 # Path, X server and arguments (if needed)
 # Note: -xauth $authfile is automatically appended
 default_path        /bin:/usr/bin:/usr/local/bin
 default_xserver     /usr/bin/X
 xserver_arguments   -nolisten tcp vt09

I am not using a second X display on my current vt, but a completely different one (I can switch between many of thise using CTRL+ALT+Fn).

If you aren't using slim, you can use a construct like this to start X on another vt:

 /usr/bin/startx -- :10 vt10

That will start X on display :10 and put it on vt10 (CTRL+ALT+F10). These don't need to match but I think it's neater if they do.

You do need your container config to make the relevant devices available, like this:

 # XOrg Desktop
 lxc.cgroup.devices.allow = c 4:10 rwm    # /dev/tty10 X Desktop
 lxc.cgroup.devices.allow = c 195:* rwm  # /dev/nvidia Graphics card
 lxc.cgroup.devices.allow = c 13:* rwm   # /dev/input/* input devices

And you need to make the devices in your container:

 # display vt device
 mknod -m 666 /dev/tty10 c 4 10

 # NVIDIA graphics card devices
 mknod -m 666 /dev/nvidia0 c 195 0
 mknod -m 666 /dev/nvidiactl c 195 255

 # input devices
 mkdir  /dev/input           # input devices
 chmod 755 /dev/input
 mknod -m 666 /dev/input/mice c 13 63 # mice

I also manually configured input devices (since we don't have udev in container)

 Section "ServerFlags"
         Option "AutoAddDevices" "False"
 EndSection

 Section "ServerLayout"
     Identifier     "Desktop"
     InputDevice    "Mouse0" "CorePointer"
     InputDevice    "Keyboard0" "CoreKeyboard"
 EndSection

 Section "InputDevice"
     Identifier "Keyboard0"
     Driver "kbd"
     Option "XkbLayout" "gb"
 EndSection

 Section "InputDevice"
     Identifier "Mouse0"
     Driver "mouse"
     Option "Protocol" "auto"
     Option "Device" "/dev/input/mice"
     Option "ZAxisMapping" "4 5 6 7"
 EndSection

The above going in a file /etc/X11/xorg.conf.d/10-input.conf

Not sure if any of that will help, but good luck!

share|improve this answer
    
I wasn't able to get this working with nouveau, or with nouveau + vesa. Any clues? Do I have to use the proprietary driver? –  Robin Green Feb 4 '12 at 22:42
    
I am using the proprietary driver. I haven't tried anything else. Are you on ArchLinux? I installed xorg-xserver and nvidia on the HOST and also inside the container. I can then install, say, xterm and twm inside the container to test it. My everyday desktop is configured around OpenBox and resides inside a container. –  starfry Feb 7 '12 at 14:39
    
I'm on Fedora. How are you testing it? What I tried was running an X server inside the container on screen :1, which failed spectacularly (the host X died). –  Robin Green Feb 7 '12 at 15:15
    
Robin, I've updated the original answer with more detail for you. –  starfry Feb 8 '12 at 9:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.