The following is all of the steps to build spartan with docker from a fresh Ubuntu installation:
- Install Docker for Ubuntu
- Make sure to
sudo usermod -aG docker your-user
and then not run below docker scripts assudo
- Install
nvidia-docker
. Make sure to usenvidia-docker1
notnvidia-docker2
as it has a known issue with OpenGL. See this issue. Follow the instructions on their webpage but replace
sudo apt-get install -y nvidia-docker2
with
sudo apt-get install -y nvidia-docker
You can test that your nvidia-docker installation is working by running
docker run --runtime=nvidia --rm nvidia/cuda nvidia-smi
If you get errors about nvidia-modprobe not being installed, install it by running
sudo apt-get install nvidia-modprobe
and then restart your machine.
- Clone, setup, and build Spartan:
git clone [email protected]:RobotLocomotion/spartan.git
cd spartan
git submodule init
git submodule update
./setup/docker/docker_build.py
./setup/docker/docker_run.py
mkdir build && cd build && use_ros && cmake .. && use_spartan && make -j8
Below is explained additional options and details of the above.
After cloning spartan and setting up submodules, from the spartan root directory run
./setup/docker/docker_build.py
to build a docker image. The default image name is <username>-spartan
where <username>
is your username on the host machine. Optionally you can pass the option -i <image_name>
to specify the name of the image. Use -h
to see a full list of command line options. Note you can also rename the image after building (see Docker Cheatsheet below).
This is a basic 16.04 environment with the necessary dependencies for spartan
installed.
To create container derived from the image that was just build run (from the spartan
root directory)
./setup/docker/docker_run.py
By default this will create a container named <username>-spartan
derived from an image named <username>-spartan
. It also creates a user named <username>
inside the docker container. By default this username will match the current username on the host machine. This is important for SSH keys used in cloning private github repos to work properly. The default password for your user inside the docker container is password
. User the -p
flag to set a different password.
This container mounts your current
spartan directory at /home/<username>/spartan
. You can use the optional command line arguments -i <image_name>
to derive a container from a specific image, and -c <container_name>
to name the container. Use -h
to see a full list of command line arguments. By default the container will be deleted upon exiting the container (due to the --rm
flag), but both the source code and the compiled binaries live outside the container.
See here for more documentation on the docker run
command.
cd /root/spartan
mkdir build && cd build
use_ros
cmake ..
use_spartan
make -j
Handling images
docker images
- lists all docker images on machine, including REPOSITORY, TAG, IMAGE_ID, when created, sizedocker tag IMAGE_ID NEW_NAME
- creates a new REPOSITORY:TAG for an IMAGE_IDdocker rmi REPOSITORY:TAG
- removes this tag for an imagedocker tag IMAGE_ID my-spartan && docker rmi spartan
-- example to combine above two commands to rename an image ID
Handling containers
docker ps -a
- lists all containers on machinedocker rm CONTAINER_ID
- removes container id