HW accelerated GUI apps on Docker

  • How much time could we save replacing the configuration of our environment (dev\CI\you-name-it..) by a docker-compose file?
  • How much easier would running N different versions of a browser be?

X window system architecture 101

simplified drawing pipeline

Containerizing a GUI app

  • we can bundle xvfb and a VNC server with our container image
  • or we can share the host’s X11 socket with the container as an external volume
What is bundled in the docker image in both approaches: the main difference is using a provided or a bundled X window system

Getting our hands dirty

xhost +local:root; \
docker run -d \
-e DISPLAY=$DISPLAY \
-v /tmp/.X11-unix:/tmp/.X11-unix:rw \
ubuntu:latest \
sh -c 'apt-get update && apt-get install -qqy x11-apps && xeyes'
  1. enables the root user to make connections to the running X server (please consider reading xhost man page)
  2. pulls and runs an instance of ubuntu:latest, mounting the host’s X11 socket and setting the host’s DISPLAY into the container environment
  3. installs and runs xeyes inside the container instance, rendering on the host’s X server
xeyes running on Docker

Enabling hardware acceleration (on Nvidia GPUs)

xhost +local:root; \
docker run -ti --rm \
-e DISPLAY=$DISPLAY \
-v /tmp/.X11-unix:/tmp/.X11-unix:rw \
ubuntu:latest \
sh -c ‘apt-get update && apt-get install -qqy mesa-utils && glxgears’

Remote system vs local system

I never got so excited watching glxgears!!!

A common ground

xhost +local:root; \
nvidia-docker run -d \
--env="DISPLAY" \
--volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \
plumbee/nvidia-virtualgl vglrun glxgears
xhost +local:root; \
nvidia-docker run -d \
--env="DISPLAY" \
--volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \
plumbee/nvidia-virtualgl \
sh -c 'apt-get update && apt-get install -qqy firefox && vglrun firefox'
nvidia-docker run -d \
--env="DISPLAY" \
--volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \
plumbee/nvidia-virtualgl sh -c 'apt-get update && apt-get install -qqy blender && vglrun blender'
3 hardware accelerated docker containers running blender, firefox, and (obviously) glxgears, on a G2.2xlarge instance on AWS

Congratulations!

--

--

--

@pigiuz on Twitter — Dad at home — Head of Engineering at SuperAwesome — views are my own

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

The Math of Easy-to-Use

5 Technologies that will Boost your Future Mobile App Strategy

SOLID Design Principles

App inside App inside App [part 1]

How To Create A Flutter Chrome Extension

To the rescue

Becoming a Frontrunner for SAP’s Industry Cloud

How to live sane QA Dev’s life in a start-up agile world.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Piergiorgio Niero

Piergiorgio Niero

@pigiuz on Twitter — Dad at home — Head of Engineering at SuperAwesome — views are my own

More from Medium

Hands-on Docker

Docker Swarm and GPUs

Concierge — AWS CloudFormation Compliance Check Tool (using CloudConformity API)

How to deploy micro-services on kbernetes, hands on tutorial !