Ask Your Question

Running ROS and its gui tools through a docker image

asked 2019-01-25 06:34:02 -0600

pitosalas gravatar image

I am experimenting creating a standard environment for my students to run ROS without having to install anything, because that always goes wrong somehow. In other posts I have questions about VNC and X. This question is similar: Is it possible, and how, to create a docker image based on Ubuntu and ROS that when launched will allow ROS development and testing to happen including running tools like Gazebo, RViz, RQT etc etc. Have you done it? Have you seen it written up? I am successful at this point to get everything to work in the container, EXCEPT trying to run say RQT which fails with "QXcbConnection: Could not connect to display" and many other errors. If desired I will attach my Dockerfile.

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted

answered 2019-01-28 12:55:18 -0600

ruffsl gravatar image

updated 2019-01-29 13:22:28 -0600

You might be interested in a small python tool from OSRF named Rocker

A tool to run docker containers with overlays and convenient options for things like GUIs etc.

It's basically helpful CLI around Docker that enables display/audio forwarding and hardware acceleration to container to simplify using ROS GUIs with Docker. I'm sure @tfoote would appreciate any feedback should you try out the project.

Edit: Just to throw it out there, you may also want to checkout web based environments for developing ROS, e.g:

However, web based environments may pose their own challenges if your intent is to also interact with physical robots locally in a lab/class room. Still I imagine a combination of the theses methods would do nicely. E.g RDS/AWS for homework and Docker/Singularity for in lab sessions.

edit flag offensive delete link more


@pitosalas: rocker is what is used in osrf/car_demo I linked to in my answer.

I still feel Singularity makes more sense in an environment with students, if only for the fact that it doesn't need super user privileges.

gvdhoorn gravatar imagegvdhoorn ( 2019-01-28 14:34:14 -0600 )edit

@gvdhoorn I looked at singularity's web site and admit I don't understand how to use it. I kind of understand what they say it does but I am lost on where to start. I did read the doc and the quick start but without a handle on what the thing does, which keeps me from just typing in the commands!

pitosalas gravatar imagepitosalas ( 2019-01-28 15:01:35 -0600 )edit

You'll want to check the user manual. Especially the quick start and introduction sections.

gvdhoorn gravatar imagegvdhoorn ( 2019-01-28 15:03:48 -0600 )edit

I did read the doc and the quick start but without a handle on what the thing does, which keeps me from just typing in the commands!

do you know what Docker does?

gvdhoorn gravatar imagegvdhoorn ( 2019-01-28 15:09:02 -0600 )edit

answered 2019-01-25 06:41:23 -0600

gvdhoorn gravatar image

updated 2019-01-28 15:20:47 -0600

(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.

edit flag offensive delete link more


+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.

ruffsl gravatar imageruffsl ( 2019-01-28 15:45:04 -0600 )edit

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. ..

gvdhoorn gravatar imagegvdhoorn ( 2019-01-29 03:44:39 -0600 )edit

.. 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".

gvdhoorn gravatar imagegvdhoorn ( 2019-01-29 03:45:51 -0600 )edit

@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

pitosalas gravatar imagepitosalas ( 2019-01-29 06:27:33 -0600 )edit

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.

gvdhoorn gravatar imagegvdhoorn ( 2019-01-29 06:35:16 -0600 )edit

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 ..

gvdhoorn gravatar imagegvdhoorn ( 2019-01-29 06:37:38 -0600 )edit

.. 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 ..

gvdhoorn gravatar imagegvdhoorn ( 2019-01-29 06:38:50 -0600 )edit

.. in a VM as any other tool would. How much of an impact there is of course depends on the types of workloads.

gvdhoorn gravatar imagegvdhoorn ( 2019-01-29 06:39:15 -0600 )edit

answered 2019-02-25 10:00:49 -0600

dratasich gravatar image

I use the latest ros image (e.g., ros:melodic) and install the ROS desktop version (my simple custom Dockerfile for the GUI tools). Then I start all GUI tools with x11docker.

Works like a charm:

$ x11docker --hostnet ros:gui rviz
$ x11docker --hostnet ros:gui rqt_graph

I'm using --hostnet (cf. --network=host) for simplicity. ros:gui is the tag of my custom Docker image.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2019-01-25 06:34:02 -0600

Seen: 1,497 times

Last updated: Jan 29