
(Strictly speaking, this is not an answer, but I needed more characters than the comment allowed)
For students, I would take a look at Singularity.
It uses the same techniques, but doesn't require super user rights, mounts $HOME by default, runs everything as the $USER that started the container, and allows access to devices and GPUs by default.
There isn't even any special configuration needed with Singularity containers to be able to use GUIs.
And it allows you to import/run/exec Docker images, so you can start from osrf/ros:kinetic-desktop-full for instance.
Edit: as an answer to your original question: yes, it's certainly possible to run GUI applications from inside Docker containers. Some of the approaches are documented over at wiki/docker. An alternative can be seen at osrf/car_demo.
Edit2: here's a three line example to get RViz running from inside a Singularity "shell" (essentially equivalent to a docker run -it ..):
# needed once: converts Docker image into Singularity image on your local system singularity pull --name ros-kinetic-desktop-full.simg docker://osrf/ros:kinetic-desktop-full # in terminal 1: roscore singularity exec -p ./ros-kinetic-desktop-full.simg bash -c 'source /opt/ros/kinetic/setup.bash; roscore' # in terminal 2: rviz # if you have nvidia hw and the proprietary driver installed: singularity exec --nv -p ./ros-kinetic-desktop-full.simg bash -c 'source /opt/ros/kinetic/setup.bash; rviz' # if you have a built-in Intel GPU or are using nouveau singularity exec -p ./ros-kinetic-desktop-full.simg bash -c 'source /opt/ros/kinetic/setup.bash; rviz'
Note: I'm using Singularity 2.5.2 commands here. Singularity 2.6 (and 3.0) will have changed the way it interacts with NVidia hw.
The -p is to make sure all child processes in the container are terminated when the container terminates.
Originally posted by gvdhoorn with karma: 86574 on 2019-01-25
This answer was NOT ACCEPTED on the original site
Post score: 3
Original comments
Comment by ruffsl on 2019-01-28:
+1 for the three line Singularity example. When you have the time, a post or wiki about using ROS with singularity would be cool. It seems v3.0 has changed up some things, but searching the docs, I didn't see anything much on nvidia/gpu.
Comment by gvdhoorn on 2019-01-29:
I've been meaning to, but as always, time and other obligations have prevented me from doing that so far.
re: 3.0 changes: yes, it's a complete rewrite (in golang) and it's changed quite a few things.
re: gpu: there is nothing special to do, as Singularity allows access to /dev by default. What is needed is to "install" the required drivers in the image. But as you don't want to do that, a similar trick to what nvidia-docker(2) did/does is used: mount those into the container. The specifics of that have changed between 2.x and 3.x, but in principle things "just work".
Comment by pitosalas on 2019-01-29:
@gvdhoorn thanks for the example. And yes of course I know docker. That's what I've been using (among other things) to get this to work. It seems that Singularity only works natively on unix and needs a VM to run on Mac, which is my environment. Will it perform ok then? I worry about docker + vm
Comment by gvdhoorn on 2019-01-29:\
And yes of course I know docker.
You wrote:
[..] without a handle on what the thing does, which keeps me from just typing in the commands!
Which made me ask myself (and you) whether you (truely) know what Docker does when you give it a command. I merely found it a curious thing to say.
It seems that Singularity only works natively on unix and needs a VM to run on Mac, which is my environment. Will it perform ok then? I worry about docker + vm
Singularity right now apparently only runs natively under Linux, but can be made to run on OSX. See sylabs/singularity#109.
I've not done that myself and it's probably not something I'd recommend doing in a production environment/class/uni course where you depend on your tools being stable.
re: vm: Singularity is not magic, so will suffer in a VM as any other tool would. How much of an impact there is of course depends on the types of workloads.
Comment by pitosalas on 2019-01-29:
It was a curious answer, and yet it was true. I would say my level of docker expertise is intermediate not expert. But really without context the singularity web site doesnt explain what it does. I couldnt even tell for sure if it was software I installed or it was a cloud service.
Comment by gvdhoorn on 2019-03-05:
Seems there is some movement on the OSX + Singularity front: sylabs/singularity#2675 just got merged.