#!/bin/sh # Run to create an lxc container that is allowed to access the nvidia card and input devices set -e set -x CONTAINERNAME=nvidia-demo if [ ! -w / ] then echo "Please run as root using sudo." exit 1 fi if test "$SUDO_USER" then REALUSER=$SUDO_USER else echo Please run with sudo, or edit this script to set REALUSER some other way. fi lxc-create -t ubuntu -n $CONTAINERNAME -- --bindhome $REALUSER # See https://lists.linuxcontainers.org/pipermail/lxc-users/2011-April/001817.html tee -a /var/lib/lxc/$CONTAINERNAME/config <<_EOF_ lxc.cgroup.devices.allow = c 4:9 rwm # /dev/tty9 X Desktop lxc.cgroup.devices.allow = c 195:* rwm # /dev/nvidia Graphics card lxc.cgroup.devices.allow = c 13:* rwm # /dev/input/* input devices _EOF_ echo "Now start the container with 'sudo lxc-start -n $CONTAINERNAME' and run demo-inner.sh inside it to install X"