0
$\begingroup$

Rosanswers logo

" sudo docker run -it osrf/ros:kinetic-desktop-full-xenial" it is working and roscore is also working , but "rosrun rviz rviz" is not working

i am using ubuntu 18.04 and ihave installed docker ,and i need to use ros kinetic , so for that i have pulled image of"osrf/ros:kinetic-desktop-full-xenial" but now im not able to use rviz and gazebo,how to install rviz and gazebo while using docker?


Originally posted by muhammed rushid s on ROS Answers with karma: 71 on 2018-08-08

Post score: 7


Original comments

Comment by NEngelhard on 2018-08-09:
Could you please use only a single sentence or question as title? (like the rest of the questions?) It does not make much sense to just paste the same text in both fields..

Comment by gvdhoorn on 2018-08-09:
Please see if the information on the wiki/docker pages sheds some light on things.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Hi there, we got RViz to work through nvidia-docker2 (with OpenGL) by following the guide here: http://wiki.ros.org/action/login/docker/Tutorials/Hardware%20Acceleration#nvidia-docker2

We had to modify the script a bit to make it work:

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

XAUTH=/tmp/.docker.xauth

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

echo "Done."
echo ""
echo "Verifying file contents:"
file $XAUTH
echo "--> It should say \"X11 Xauthority data\"."
echo ""
echo "Permissions:"
ls -FAlh $XAUTH
echo ""
echo "Running docker..."

docker run -it \
    --env="DISPLAY=$DISPLAY" \
    --env="QT_X11_NO_MITSHM=1" \
    --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \
    --env="XAUTHORITY=$XAUTH" \
    --volume="$XAUTH:$XAUTH" \
    --net=host \
    --privileged \
    --runtime=nvidia \
    our-nvidia-based-ros-melodic-image-plus-nvidia-env-vars-from-the-guide:latest \
    bash

echo "Done."

Note 1: We added the tail -n 1 into the xauth sequence since the original command resulted in two identical lines after the sed replacement. So we only took one of them.

Note 2: The --net=host and --privileged are only needed if you want to join the host pc network. We added it to test communication with RViz by playing a bag-file from the outside using rosbag play and seeing the images being received by RViz.


Originally posted by JBruun with karma: 46 on 2020-07-02

This answer was ACCEPTED on the original site

Post score: 3


Original comments

Comment by sgarciav on 2021-06-09:
The link you provided for installing the nvidia-docker2 package was excellent thanks! I did find these instructions for installing the package easier to follow.

The provided script for running the container did not work for me. I had to rely on docker-compose to build the image and run the container. You can find the docker-compose.yml file I'm using in this Github gist. Make sure you download it into the same directory where you have your Dockerfile. cd into the directory where both files live and execute the following:

  • $ docker-compose build: to build the image
  • $ docker-compose up -d: to spin the container
  • $ docker exec -it [CONTAINER NAME] /bin/bash: to be dropped into the container

At this point you should be dropped into the container and you

Comment by zkytony on 2022-01-11:
This worked for me. Thanks! You don't have to use nvidia. I built a Dockerfile from the ros:kinetic image.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.