How to view Gazebo and RViz GUIs through Docker whilst sharing connection?
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?