ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
5

Running ROS and its gui tools through a docker image

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

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

4 Answers

Sort by ยป oldest newest most voted
3

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

gvdhoorn gravatar image

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

(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

Comments

1

+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 image ruffsl  ( 2019-01-28 15:45:04 -0500 )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. 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 image gvdhoorn  ( 2019-01-29 03:44:39 -0500 )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 image pitosalas  ( 2019-01-29 06:27:33 -0500 )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.

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

gvdhoorn gravatar image gvdhoorn  ( 2019-01-29 06:35:16 -0500 )edit

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.

pitosalas gravatar image pitosalas  ( 2019-01-29 06:46:51 -0500 )edit

Seems there is some movement on the OSX + Singularity front: sylabs/singularity#2675 just got merged.

gvdhoorn gravatar image gvdhoorn  ( 2019-03-05 12:03:04 -0500 )edit
3

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

ruffsl gravatar image

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

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.

https://github.com/osrf/rocker

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

Comments

@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 image gvdhoorn  ( 2019-01-28 14:34:14 -0500 )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 image pitosalas  ( 2019-01-28 15:01:35 -0500 )edit

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

gvdhoorn gravatar image gvdhoorn  ( 2019-01-28 15:03:48 -0500 )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 image gvdhoorn  ( 2019-01-28 15:09:02 -0500 )edit
1

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

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

Comments

I am on Mac so x11docker is not available to me... :(

pitosalas gravatar image pitosalas  ( 2020-01-18 08:10:38 -0500 )edit
1

answered 2020-02-11 08:30:55 -0500

Johann.Haselberger gravatar image

For those, who are still looking for an easy ROS usage: https://hub.docker.com/r/johannhaselb...

This will allow you to use all ROS GUI tools within your browser - on mac, linux and even windows.

edit flag offensive delete link more

Comments

@Johann.Haselberger thanks. I am not sure how I launch your docker container from there. Can you give me the sequence? Thanks.

pitosalas gravatar image pitosalas  ( 2020-03-04 16:33:13 -0500 )edit

@Johann.Haselberger can I ask you a question about #coros?

pitosalas gravatar image pitosalas  ( 2020-04-23 17:08:01 -0500 )edit

@pitosalas: Yes feel free to ask, you could also create an issue on the GitHub project.

Also on docker hub / GitHub there is a small documentation. The section Start the service is exactly what you are looking for.

Johann.Haselberger gravatar image Johann.Haselberger  ( 2020-04-24 02:11:34 -0500 )edit

@Johann.Haselberger thanks. I tried it on a cloud host and it worked and now I am trying it locally on my Mac and it seems to work nicely too. Question: it says FROM ros:melodic but where is that Dockerfile so I can see what it is doing?

pitosalas gravatar image pitosalas  ( 2020-04-25 10:56:18 -0500 )edit

Question Tools

3 followers

Stats

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

Seen: 7,550 times

Last updated: Feb 11 '20