Create and use Docker images for ZED and ROS
In this section, we guide you to create a docker image that can run ROS and ZED SDK.
Dockerfile Overview
Specify the parent image
In this section, we first specify the parent Docker image to pull a ZED SDK Docker image. The Ubuntu release year, SDK and CUDA versions are passed as arguments
The above section remains the same for both ROS and ROS 2 Dockerfiles.
Install ROS
Once you have specified the source image, you can go ahead and decide on the ROS distribution to be installed.
This Dockerfile.ros installs dependencies based on the versions mentioned, be careful to check the version availability and compatibility.
Setup the ROS workspace
This final section lets you set up the ROS workspace and get ready to install ROS packages.
Entrypoint
As you can see Dockerfile.ros contain the command ENTRYPOINT ["/ros_entrypoint.sh"]. The ENTRYPOINT specified is the default executable of the image which runs the script ros_entrypoint.sh every time the image is run. You can find this file along with the Dockerfiles here.
ros_entrypoint.sh makes sure that the setup.bash file is sourced every time when the image is run.
Make sure that this file is present along with your Dockerfile when you build and run the image.
Build Script Overview
Just like the build script for OpenCV dockerfiles, the build-ros-desktop-image.sh file lets you configure the versions which are passed during the build. The script is detailed below.
Configure the arguments
The build arguments remain the same as that of the OpenCV Dockerfile build arguments, except here instead of having the OPENCV_VERSION we have an argument ROS_2_FLAG.
The ROS distro is selected based on the UBUNTU_RELEASE_YEAR , when the release year is 20 ROS_2_FLAG lets you choose between ROS or ROS 2, when the flag is set to 0 ROS distro noetic is installed and when set to 1 ROS 2 Foxy Fitzroy is installed.
These values are default and can be changed to the versions that you intend to build.
Check for version compatibility
In addition to checking for the versions compatibility it also assigns corresponding $ROS_DISTRO based on the UBUNTU_RELEASE_YEAR.
Docker build
This section of the script executes docker build for creating the Docker image, since a single script is used to build both ROS and ROS 2 Docker images, the default tag is assigned based on the ROS_2_FLAG. Accordingly, different Dockerfiles are chosen for the build.

