Dockers are similiar to virtual machines, but lighter weight. This will allow for your computer to be running the newest version of linux and still run ROS melodic in an Ubuntu 18.04 enviroment. Another benefit is you can create an image per project that has all of the reqirements for that project installed and give it to someone else to run.
Guide:
- Follow install instructions here: https://docs.docker.com/engine/install/ubuntu/
- If you are running a Nvidia GPU and you want gui support follow these instructions to install nvidia_docker2: https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html
- The first step has you installing docker skip that part but do run:
sudo systemctl --now enable docker
- The first step has you installing docker skip that part but do run:
- To get a base image of ubuntu 18.04 with ros melodic full desktop installed: (There may already be a based image for the project you're on)
- Run everytime booting up computer: (This allows docker enviroments to display images)
xhost +local:docker &> /dev/null
- To create the docker container run the following:
(This will open a bash window in the container, also it will install and setup the ROS workspace for the infrastructure project)
DOCKER_COMMON_ARGS="--gpus all --env=NVIDIA_VISIBLE_DEVICES=all --env=NVIDIA_DRIVER_CAPABILITIES=all --env=DISPLAY --env=QT_X11_NO_MITSHM=1 -v /tmp/.X11-unix:/tmp/.X11-unix:rw"
sudo docker run -it --net=host --privileged $DOCKER_COMMON_ARGS --name <name_of_container> grimmlins/infrastructure:base_image
- In a new terminal run:
sudo docker exec -it <name_of_container> bash
- Run everytime booting up computer: (This allows docker enviroments to display images)
-
If you want guis(run in a host os terminal not the terminal for the container):
xhost +local:docker &> /dev/null
- Add it to the .bashrc file for the host machine if you don't want to run this command every session.
-
Start the container:
sudo docker start <name_of_container>
-
Access the bash of the container:
sudo docker exec -it <name_of_container> bash
- See running containers:
sudo docker ps
- See all containers on computer:
sudo docker container list -a
- Stop the container once you are done:
sudo docker stop <name_of_container>
- When working with a usb device the easiest method is to give the container --privileged access when doing the docker run command. (This method does have security risks) Ensure to plug in the device before executing the "docker start ".
- If the container is already running use the stop command plug in usb device then execute the start command.