Skip to content

Instantly share code, notes, and snippets.

@tomzo
Created October 3, 2015 08:07
Show Gist options
  • Save tomzo/7812292a2fc8d9118f2c to your computer and use it in GitHub Desktop.
Save tomzo/7812292a2fc8d9118f2c to your computer and use it in GitHub Desktop.
Running docker with X on host and GPU acceleration - PoC
#!/bin/bash
# Install host GPU drivers
# ...
# Start a bare X-server
X :0 &
# Make it possible to connect from other hosts
export DISPLAY=:0
xhost +
# There is extra requirements for the image
# 1. Must have installed exactly the same drivers that host has
# 2. Should have some desktop environment installed. I use xfce4, it works well in this case.
docker run -ti \
--privileged \
-e "DISPLAY=unix:0.0" \
--volume "/tmp/.X11-unix:/tmp/.X11-unix:rw" \
yourimage /bin/bash
# Now
if you start any X application then it should show up.
You can test GPU acceleration by installing mesa-utils and running glxgears
If the image has xfce4 then you can start a full-blown desktop environment by running `startxfce4`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment