NOTE: This approach is a bit of a hack. It also does not support copy and paste between host and guest - and is totally insecure!
- Add
/tmp as an additional filesystem in the guest configuration, which passes through to /tmp on the host. - Ensure that your X server is not configured to accept network connections of any kind, because the next step disables X security.
- Type
xhost + in a terminal window. - Start the LXC guest
- Log in as your desired ordinary user inside the guest (i.e. not as root), and type
DISPLAY=:0 Xephyr :2 -screen 1024x768 -dpi 96 &
DISPLAY=:2 /etc/X11/xinit/Xsession
inside the guest (replacing both 2s with the number of the screen to use if you are using this to connect to multiple LXC VMs.) Adjust the resolution (-screen) and DPI (-dpi) parameters to suit.
What this does is sets up "proxy" connections to a Xephyr nested X server running in the guest (which use both UNIX domain sockets and the MIT-SHM extension) and another connection from Xephyr to your host X server (which uses UNIX domain sockets, but cannot, as far as I can determine, use MIT-SHM, due to the design of LXC). This seems to be the fastest configuration possible with an LXC guest, at least with the open source driver for my hardware (nvidia).