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

How to view Gazebo and RViz GUIs through Docker whilst sharing connection?

asked 2020-11-16 02:37:56 -0500

Py gravatar image

I have a Docker container running a robot simulation through Gazebo with data visualised through RViz. This seems to work great until I use the --net=host option to make its topics available to subscribe and publish to from another ROS system running on the host. The error message I get on the container is as follows (similar for Gazebo):

process[rviz-9]: started with pid [261]
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
dbus[261]: The last reference on a connection was dropped without closing the connection. This is a bug in an application. See dbus_connection_unref() documentation for details.
Most likely, the application was supposed to call dbus_connection_close(), since this is a private connection.
  D-Bus not built with -rdynamic so unable to print a backtrace
[rviz-9] process has died [pid 261, exit code -6, cmd /opt/ros/melodic/lib/rviz/rviz -d /workspace/src/simulation/config/rviz_config.rviz __name:=rviz __log:=/root/.ros/log/4a62825e-27e5-11eb-bb41-50eb712545a4/rviz-9.log].
log file: /root/.ros/log/4a62825e-27e5-11eb-bb41-50eb712545a4/rviz-9*.log

Here's the script I used to run the container:

#!/bin/bash

xhost +local:root

XAUTH=/tmp/.docker.xauth
if [ ! -f $XAUTH ]
then
    xauth_list=$(xauth nlist :0 | sed -e 's/^..../ffff/')
    if [ ! -z "$xauth_list" ]
    then
        echo $xauth_list | xauth -f $XAUTH nmerge -
    else
        touch $XAUTH
    fi
    chmod a+r $XAUTH
fi

docker run -it \
    --rm \
    --net=host \
    --env="DISPLAY=$DISPLAY" \
    --env="QT_X11_NO_MITSHM=1" \
    --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \
    --env="XAUTHORITY=$XAUTH" \
    --volume="$XAUTH:$XAUTH" \
    --runtime=nvidia \
    simulation:latest \
    roslaunch simulation simulation.launch
export containerId=$(docker ps -l -q)

xhost -local:root

Any ideas what I might have done wrong?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2020-11-16 07:07:20 -0500

Py gravatar image

I solved this by adding --privileged before --net=host.

edit flag offensive delete link more
0

answered 2022-03-14 03:29:17 -0500

brianlmerritt gravatar image

According to this article https://www.cloudsavvyit.com/10520/ho... you run some security risks when you open up an X socket, but you reduce the risks massively by not running --privileged.

Some extra info here about not running a container as root

https://www.thegeekdiary.com/run-dock...

This is maybe a bit late for you but hopefully will help anyone else who finds this working but insecure answer.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2020-11-16 02:37:56 -0500

Seen: 1,727 times

Last updated: Mar 14 '22