Wednesday, May 1, 2024
 Popular · Latest · Hot · Upcoming
4
rated 0 times [  4] [ 0]  / answers: 1 / hits: 5658  / 1 Year ago, fri, december 23, 2022, 3:33:12

Since LXC (Linux Containers) is a kernel level super-chroot, I've been wondering what sort of video driver the containers have:



My host is Ubuntu 12.04 64-bit machine with ATI gpu. Will the LXC container have access to the same driver? Or do they need to be installed on each container?


More From » 12.04

 Answers
6

Please, take a look at this script to create a LXC container that runs steam with sound and video acceleration:



http://bazaar.launchpad.net/~ubuntu-lxc/lxc/steam-lxc/view/head:/steam-lxc



The magic comes here:



Outside LXC:



    # Add the bind mounts to the container's fstab
self.container.set_config_item("lxc.mount.entry",
"/tmp/.X11-unix tmp/.X11-unix "
"none bind,ro")
self.container.set_config_item("lxc.mount.entry",
"/dev/dri dev/dri none bind,ro")
self.container.set_config_item("lxc.mount.entry",
"%s/pulse.socket home/%s/.pulse_socket "
"none bind,ro" % (self.config_path,
self.user.pw_name))


We export X11 with a bind mount the /tmp/.X11-unix directory to allow container to use host X11. Do the same with /dev/dri directory and audio socket.



Inside LXC:



    # Get pulseaudio to listen on the socket
with self.user_privileges():
subprocess.call(['pactl', 'load-module',
'module-native-protocol-unix',
'socket=%s' % self.pulse_socket,
'auth-cookie-enabled=0'])

# Start steam
self.run_command(
["steam"], {'DISPLAY': os.environ['DISPLAY'],
'PULSE_SERVER': "/home/%s/.pulse_socket" %
self.user.pw_name})


Uses pactl to use a unix socket to communicate with host pulse audio server and later export the socket and DISPLAY environment variable to allow steam to use local X11 server and socket to audio server.



Take a look at the script and enjoy it :)



With that environment variables inside LXC you could play (theoretically) almost all games.



Best regards!


[#33883] Sunday, December 25, 2022, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
anoalk

Total Points: 271
Total Questions: 90
Total Answers: 112

Location: Zambia
Member since Wed, Dec 16, 2020
3 Years ago
anoalk questions
Wed, Mar 15, 23, 04:06, 1 Year ago
Fri, Sep 24, 21, 02:59, 3 Years ago
Sat, Mar 5, 22, 02:33, 2 Years ago
Tue, Mar 22, 22, 07:19, 2 Years ago
;