The Dockerfile contains all commands for
- setting up TensorFlow GPU.
- creating a workspace
- installing ROS kinetic and some Python packages
The first point happens by making our image inherit from tensorflow/tensorflow:latest-gpu-py3.
The docker-compose.yml file is responsible for bind mounting the entrypoint.sh and the scripts directory into the container. Bind mounting allows us to make changes on those files on the host machine, while having all changes being reflected in your container. An alternative would be to declare COPY commands in the Dockerfile however any changes to these files would be required to happen inside the Docker container and those changes would be isolated from the original files on the host machine. I use COPY for static files which do not need to change and bind mount those files which are under development.
To avoid having to set up NVIDIA CUDA manually, we use the NVIDIA Container Runtime. This is specified in side the docker-compose.yml.
For the runtime: nvidia command to work inside the yaml file, we need it to be version: '2.3'. tty: true makes sure, the container does not get shutdown instantly after the docker-compose up command.
The entrypoint.sh gets executed, whenever a container gets started. It checks, whether the dummy ROS package tutorial already exists, and if not, it creates it. That means, it happens only at the first start-up.