This directory contains a few Dockerfiles and supporting scripts. See each section below for usage information about
This section describes how to build and run a docker image based on nightly builds of downstream Gazebo libraries. The Docker image will use the Gazebo code found in the current source tree.
Requirements
-
Optional: Install NVidia Docker
Nvidia docker will be needed if you plan to run the GUI and/or sensors after the Docker image is built.
Steps
-
Change the root directory of the Gazebo Sim source tree. If you are currently in the
docker
subdirectory:cd ..
-
Build the gz-sim:base image.
docker build . -f ./docker/Dockerfile.base -t gz-sim:base
-
Build the nightly docker image.
docker build . -f ./docker/Dockerfile.nightly -t gz-sim:nightly
-
Run the docker image with a bash shell.
docker run -it gz-sim:nightly /bin/bash
-
Alternatively, you can directly run Gazebo using
./docker/run.bash gz-sim:nightly gz-sim-server -v 4
This section describes how to build and run a docker image of a Gazebo distribution using debians.
Requirements
Steps
-
Build a docker image using the
build.bash
command. The first argument must be the name of the Gazebo distribution. The list of Gazebo distribution can be found at Gazebo distribution. For example, to build an image of Gazebo Garden:./build.bash gz-garden ./Dockerfile.gz
-
Run the docker image using
run.bash
, and pass in the name of the docker image (first argument to the build.bash script)../run.bash gz-garden
-
You can pass arguments to Gazebo by appending them the
run.bash
command. For example, to load the shapes.sdf file:./run.bash gz-garden -f shapes.sdf
Here you'll find general information, such as installation of Docker and how to use Nvidia with Docker.
Docker has two available versions: Community Edition (CE) and Enterprise Edition (EE). In this tutorial, we'll install the CE version.
-
Remove old versions of Docker (if installed):
sudo apt-get remove docker docker-engine docker.io
-
Install dependencies and keys.
sudo apt install curl apt-transport-https ca-certificates curl software-properties-common # Add the official GPG key of Docker curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
-
Setup Docker.
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
-
Install Docker
sudo apt-get update && sudo apt-get install docker-ce
-
Check your Docker installation:
sudo docker run hello-world
-
You should see the message
Hello from Docker!
confirming that your installation was successfully completed.
-
Remove old versions of Nvidia Docker:
docker volume ls -q -f driver=nvidia-docker | xargs -r -I{} -n1 docker ps -q -a -f volume={} | xargs -r docker rm -f sudo apt-get purge -y nvidia-docker
-
Setup the Nvidia Docker repository.
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add - distribution=$(. /etc/os-release;echo $ID$VERSION_ID) curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list sudo apt-get update
-
Install Nvidia Docker (version 2):
sudo apt-get install -y nvidia-docker2
-
Restart the Docker daemon
sudo service docker restart
-
Verify the installation:
docker run --gpus all --rm nvidia/cuda nvidia-smi
This command should print your GPU information, for example:
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 390.116 Driver Version: 390.116 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 GeForce GTX 960 Off | 00000000:01:00.0 On | N/A |
| 0% 51C P5 12W / 160W | 775MiB / 2000MiB | 1% Default |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
+-----------------------------------------------------------------------------+