Skip to content

henry2423/docker-ros-x11

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Docker container images with ROS, Gazebo, X11 windows and Tensorflow capability

This repository developed from nvidia/opengl and nvidia/cuda conatiners, combine these two together to create a ROS develope environment in docker

Current Image Build:

  • henry2423/ros-x11-ubuntu:melodic : Ubuntu 16.04 with ROS melodic + Gazebo 9

  • henry2423/ros-x11-ubuntu:kinetic : Ubuntu 16.04 with ROS Kinetic + Gazebo 8

Requirement

  • Docker and Nvidia-docker(docker nvidia runtime) on the host: Check with NVIDIA/nvidia-docker

  • X11 Server install:

    $ apt-get install xauth xorg openbox
    

Usage

  • For the first time before runing up the docker, you should setup X11 socket and X11 auth files by runing command:

    XSOCK=/tmp/.X11-unix
    XAUTH=/tmp/.docker.xauth
    touch $XAUTH
    xauth nlist $DISPLAY | sed -e 's/^..../ffff/' | xauth -f $XAUTH nmerge -
    
  • Run command with x11 configuration, to set up the display environment:

    nvidia-docker run -it \
      --volume /tmp/.X11-unix:/tmp/.X11-unix:rw \
      --volume /tmp/.docker.xauth:/tmp/.docker.xauth:rw \
      --env "XAUTHORITY=/tmp/.docker.xauth" \
      --env "DISPLAY" \
      --volume /etc/passwd:/etc/passwd \
      --volume /etc/group:/etc/group \
      --user $(id -u):$(id -g) \
      henry2423/ros-x11-ubuntu:kinetic \
      bash
    
  • If you want to connect to tensorboard, run command with mapping to local port 6006:

    nvidia-docker run -it \
      -p 6006:6006 \
      --volume /tmp/.X11-unix:/tmp/.X11-unix:rw \
      --volume /tmp/.docker.xauth:/tmp/.docker.xauth:rw \
      --env "XAUTHORITY=/tmp/.docker.xauth" \
      --env "DISPLAY" \
      --volume /etc/passwd:/etc/passwd \
      --volume /etc/group:/etc/group \
      --volume /etc/shadow:/etc/shadow \
      --user $(id -u):$(id -g) \
      henry2423/ros-x11-ubuntu:kinetic \
      bash
    
  • Build an image from scratch:

    docker build -t henry2423/ros-x11-ubuntu .
    

Detail Environment setting

1) Connecting jupyter notebook within container

  • Run command with mapping to local port 8888 (jupyter protocol) and 8888 (host web access):

    nvidia-docker run -it \
      -p 8888:8888 \
      --volume /tmp/.X11-unix:/tmp/.X11-unix:rw \
      --volume /tmp/.docker.xauth:/tmp/.docker.xauth:rw \
      --env "XAUTHORITY=/tmp/.docker.xauth" \
      --env "DISPLAY" \
      --volume /etc/passwd:/etc/passwd \
      --volume /etc/group:/etc/group \
      --volume /etc/shadow:/etc/shadow \
      --user $(id -u):$(id -g) \
      henry2423/ros-x11-ubuntu:kinetic \
      bash
    
  • Check your container assigned IP using $ifconfig within container, then you can start up jupyter notebook in container with following command:

    jupyter notebook --ip={YOUR CONTAINER IP} --port=8888 --allow-root
    
  • After start up the jupyter kernel, you can access the notebook from host browser through HTTP service.

    http://localhost:8888/
    

Connect & Control

If the container runs up, you can connect to the container throught the following

  • You can open the GUI program directly, such as rviz and gazebo
  • Connect to Tensorboard if you do the tensorboard mapping above: http://localhost:6006
  • Connect to Jupyter if you do the tensorboard mapping above: http://localhost:8888/
  • The username and password in container is same as your host account