This template is a starting point for ROS1 Noetic development inside Docker. It contains full Noetic desktop package, compilers (gcc) and language servers (clangd, ccls) for CPP, programming tools like git and grep, last but not least tmux terminal multiplexer. Also my favorite text editor Neovim comes installed with many plugins and configurations.
I made this template because latest ROS1 version, Noetic, runs only on Ubuntu 20.04 and I happen to be using Ubuntu 22.04. Instead of building Noetic from source, I prefer running it inside Docker container.
The Dockerfile contains my personal dotfiles for bash, tmux and Neovim. So feel free to fork the repo and tailor it to your liking.
- bat : cat clone with syntax highlighting
- ccls : C/CPP language server
- clangd : C/CPP language server
- clang-format : C/CPP file formatter
- curl : file downloader
- fd-find : find alternative
- fzf : fuzzy file finder
- git : version control tool
- grep : pattern matcher
- language-pack-en : ubuntu language packs for English
- less : file pager
- iproute2 : ip tools
- openssh-server : ssh server if you want to connect with SSH
- python3 : Python3 programming language
- python3-pip : package manager for Python3
- sudo
- tmux : terminal multiplexer
- tree : tree like file viewer
- wget : file downloader
- xauth : authorization utility for X servers
- xclip : system clipboard manager
- nodejs : needed for Neovim plugins
- cmake-language-server : LSP for cmake
- autopep8 : formatter for Python
- flake8 : linter for Python
- neovim : text editor
- This is tested using Ubuntu 22.04 installed Linux machine. Docker image should run fine in a Windows machine but X Window setup differs. You must install an X server application like VcXsrv Windows X Server.
- This is tested using a machine with NVIDIA GPU. Docker container uses host computer's GPU using NVIDIA Container
Toolkit. For different GPU vendors, some tweaks such as disabling GPU support in
run_docker.sh
might be needed. - Docker engine must be installed on the host OS.
- X Window Authorization:
-
Install
xauth
andxhost
if you don't have them.sudo apt update && sudo apt install -y xauth xhost
-
If you don't have
~/.Xauthority
file, generate with the following command:xauth generate $DISPLAY . trusted
-
Allow local connections to your X Window server. This step allows your container to access host X Window without using
--net=host
Docker run option.# Don't forget the trailing colon xhost +local:
-
- NVIDIA Container Toolkit must be installed on the host OS.
-
Add your CPP code to the
package/src
folder. -
Modify
package/CMakeLists.txt
andpackage/package.xml
to suit your project's needs. -
Modify
Dockerfile
to suit your project's needs. Install needed programs and clone needed libraries. -
Modify
entrypoint.sh
. Source workspaces, export environment variables and addbash
aliases here. -
Build Docker image.
sudo docker build -t "ros-dev" docker
-
Run Docker container using the bash script
run_docker.sh
../run_docker.sh <image_name> <container_name>
-
Docker container starts with a
tmux
session.tmux
settings are defined in the~/.tmux.conf
. Default prefix is set toCtrl
+Space
for outertmux
session, andCtrl
+A
for innertmux
session (if using nestedtmux
). -
Attach to the same container from another terminal if you need to.
docker exec -it bash <container_name>
-
Run
catkin_make
to build packages and createcompile_commands.json
insidebuild
directory. -
If you want to edit source codes inside package, run
nvim
from the root workspace directory which is~/catkin_ws
. This wayccls
LSP can properly accesscompile_commands.json
and index your includes.
- A Guide to Docker and ROS - Robotic Sea Bass - How to setup Docker for ROS development
- MashMB/nvim-ide - Neovim as IDE in Docker container
- nachovizzo/ros_in_docker - Run all your ROS1 nodes inside a completely isolated development environment
ROS Docker GUI Template is free software published under the MIT license. See LICENSE for details.