Attention
If you are looking for a better solution go and checkout osrf's rocker repository
Dockerized ROS Environment
This "package" allows you to create docker images where you can run graphical programs like Gazebo without effort. Docker image is based on official ROS docker images, but it can easily be changed to something else.
Here is the list that i didn't done yet™:
- Cross platform container support for network and UI operations
- Support for NVidia Graphics Cards
Installation
There is no need to install this "package". But if you wish you can do something like:
- Create some local directory like
~/.dockerize
- Clone this repository in
~/.dockerize
- Create symlink to
~./.dockerize/dockerize.sh
/usr/local/bin/dockerize
- Call
ROS_VERSION=noetic dockerize
anywhere
cd ~
git clone https://github.com/incebellipipo/dockerize .dockerize
sudo ln -s ~/.dockerize/dockerize.sh /usr/local/bin/dockerize
Usage
Build images
Building images is pretty straight forward, only consumed variable here is ROS_VERSION
environment variable. It could be set to versions of ROS which are published in docker hub.
export ROS_VERSION=kinetic
./dockerize.sh build
Run images
./dockerize.sh run
In order to run graphics applications like gazebo, you need to be in video
group. The user after you logged in to docker container is won't be in all groups where your local user belongs even though all user variables will be shared. As a quick work around you need to be logged in once again by using su
command
# Inside Docker
$ su - ${USER}
Password:
I personally recommend tmux after that.
Attaching running container
./dockerize.sh attach
Stopping running container
./dockerize.sh stop
Cleaning detached containers
./dockerize.sh clean
Nvidia driver setup inside the container
On the host
version="$(glxinfo | grep "OpenGL version string" | rev | cut -d" " -f1 | rev)"
wget http://us.download.nvidia.com/XFree86/Linux-x86_64/"$version"/NVIDIA-Linux-x86_64-"$version".run
mv NVIDIA-Linux-x86_64-"$version".run NVIDIA-DRIVER.run
In the container
sudo ./NVIDIA-DRIVER.run -a -N --ui=none --no-kernel-module
Credits: https://stackoverflow.com/a/44187181
Customization
Customize just like create any other Dockerfile.