ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

using RViZ in Docker

asked 2021-11-18 01:48:08 -0600

MarJooBa gravatar image

updated 2021-11-19 04:18:50 -0600

Hello everybody,

i would like to use Rviz in a Docker Container with ROS-Kinetic, which is using also on the host system. The host-system has this software and hardware implemented:

  • Ubuntu 16.04
  • ROS-Kinetic
  • Nvidia GTX 1060 and the driver 384.130
  • installed nvidia-docker2

The idea is to create a docker-container from the current software version, to update the whole system later. So i found this Introduction on ROS Wiki, which I need to visualize the container. So i tried the nvidia-docker2 part, but it doesnt worked. I running the container with the following arguments:

docker run –name doc_geste –gpus all –network host –env=DISPLAY -env=NVIDIA-VISIBLE_DEVICES=all -env=NVIDIA_DRIVER_CAPABILITIES=all –env=QT_X11_NO_MITSHM=1 -v /tmp/.X11-unix:/tmp/.X11-unix:rw –runtime=nvidia –privileged -it docker_geste

Before i started the docker container i enter the following line in the terminal: xhost +local:docker

The error which i get is:

libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
Could not initialize OpenGL for RasterGLSurface, reverting to RasterSurface.

My Dockerfile (i edit some of this line):

FROM stereolabs/zed:2.2-devel-cuda9.0-ubuntu16.04

# Possible to use "Source" 

RUN rm /bin/sh && ln -s /bin/bash /bin/sh

# nvidia-container-runtime

# Setup ROS
RUN apt-get update -y && \
    DEBIAN_FRONTEND=noninteractive apt-get install -y tzdata && \
    sh -c 'echo "deb $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list' && \
    apt-key adv --keyserver hkp:// --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654 && \
    apt-get update -y && \
    DEBIAN_FRONTEND=noninteractive apt-get -y --no-install-recommends install ros-kinetic-desktop-full ros-kinetic-openni2-* python-rosinstall python-rosdep python-rosinstall-generator python-wstool build-essential nano python-catkin-tools git openssh-server nano net-tools iputils-ping python-numpy python-scipy python-matplotlib ipython ipython-notebook python-pandas python-sympy python-nose  ros-kinetic-rosbridge-server ros-kinetic-twist-mux ros-kinetic-cob-scan-unifier ros-kinetic-joy software-properties-common ros-kinetic-ddynamic-reconfigure-python x11-xserver-utils mesa-utils libgl1-mesa-glx\
    cmake usbutils git -y --allow-unauthenticated && \
    rm -rf /var/lib/apt/lists/*

RUN add-apt-repository ppa:gijzelaar/snap7; \
    apt-get update && apt-get install -y --no-install-recommends libsnap7-dev libsnap71; \
    mkdir -p /root/.ssh/ #&& chmod 700 /root/.ssh


RUN rosdep init && \
    rosdep update --rosdistro kinetic && \
    cd /home/ && mkdir -p robot/fifi_geste_ws/src/

WORKDIR /home/robot/


RUN tar -xzvf cudnn-9.0-linux-x64-v7.tgz; \
     cp cuda/include/cudnn*.h /usr/local/cuda/include; \
     cp -P cuda/lib64/libcudnn* /usr/local/cuda/lib64; \ 
    chmod a+r /usr/local/cuda/include/cudnn*.h /usr/local/cuda/lib64/libcudnn*; \
    rm cudnn-9.0-linux-x64-v7.tgz; \
    rm -r cuda

RUN cd fifi_geste_ws/src; \
    #Get the ROS-Package in my Workspace
    rm -rf /var/lib/apt/lists/* && cd .. && \
    catkin_make -DCMAKE_BUILD_TYPE=Release -DCMAKE_LIBRARY_PATH=/usr/local/cuda/lib64/stubs -DCUDA_CUDART_LIBRARY=/usr/local/cuda/lib64/stubs -DCMAKE_CXX_FLAGS="-Wl,--allow-shlib-undefined"; \
    rm /root/.ssh/id_ed25519

COPY /Docker_Geste/SN16233.conf /usr/local/zed/settings/

My SH-FIle

# If not working, first do: sudo rm -rf /tmp/.docker.xauth
# It still not working, try running the script as root.


echo "Preparing Xauthority data..."
xauth_list=$(xauth nlist :0 | tail -n 1 | sed -e 's/^..../ffff/')
if ...
edit retag flag offensive close merge delete


Please take a look at this prior answer:

It’s for ROS Melodic but I believe you can use it for Kinetic as well. There is confirmation as recent as of June 2021

osilva gravatar image osilva  ( 2021-11-18 10:55:37 -0600 )edit

so i tried this, but it didnt worked. I get the same error again.

I add with my my docker_file and the SH-File on the question.

MarJooBa gravatar image MarJooBa  ( 2021-11-19 04:11:58 -0600 )edit

1 Answer

Sort by » oldest newest most voted

answered 2021-11-23 08:30:31 -0600

MarJooBa gravatar image

My solution is to use this image to get it with cuda and opengl. Then installing ros, some tools and the dependencies. Then I create the docker with the following parameters:

docker run –name ContainerName –gpus all –network host –env=DISPLAY –env=NVIDIA_DRIVER_CAPABILITIES=all -env=NVIDIA-VISIBLE_DEVICES=all –env=QT_X11_NO_MITSHM=1 -v /tmp/.X11-unix:/tmp/.X11-unix:rw –runtime=nvidia –privileged -it DockerImage

And it worked!

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: 2021-11-18 01:48:08 -0600

Seen: 2,367 times

Last updated: Nov 23 '21