Creating a Docker Image for your ZED Application
This is the recommended workflow for creating your own Docker image for your application:
- Write a Dockerfile for your application.
- Build the image with the
docker buildcommand. - Host your Docker image on a registry.
- Pull and run the image on the target machine.
Write the Dockerfile
Docker builds images automatically by reading the instructions in a Dockerfile: a text file that contains all the commands needed to assemble a given image.
In the following example, we will build and run the Hello ZED tutorial application in a container.
First, let’s prepare the host with the source code:
Open a text editor and create a new Dockerfile with the following content:
We pass a few extra arguments to CMake so that CMake and GCC can find all the required CUDA libraries. We also tell the linker to allow linking even when there are undefined symbols from libraries such as nvcuvid, which are not yet available at build time. These libraries are provided at runtime by the NVIDIA® Container Toolkit.
For more information on writing Dockerfiles, see the Dockerfile reference documentation.
Build your Docker Image
Now that you have created a Dockerfile, it’s time to build your image with the docker build command.
Tip: On NVIDIA® Jetson™, we recommend building your Jetson™ Docker image on an x86 host and running it on the target device to avoid long compilation times on boards such as the NVIDIA® Jetson™ Orin™ Nano.
Test the Image
Let’s start a container from the image we just created using the docker run command.
On NVIDIA® Jetson™ or with older Docker versions, use these arguments instead:
If you use a ZED X or ZED X One camera, you need a few extra shared volumes:
You should now see the output in your terminal:
When running a Docker image on an NVIDIA® Jetson™ device, make sure the L4T (Linux for Tegra) version of your host system matches the L4T version of the container you are using.
Volumes
When running a Docker image for ZED cameras, a few volumes should be shared with the host.
- [required]
/dev:/dev: required to share the video devices. - [optional]
/usr/local/zed/resources:/usr/local/zed/resources: if you plan to use the AI module of the ZED SDK (Object Detection, Body Tracking, NEURAL depth), we recommend bind-mounting a folder to avoid downloading and optimizing the AI models every time the container is restarted. The first time you use an AI model inside the container, it is downloaded and optimized into the bind-mounted folder, then reused on subsequent runs. - For GMSL2 cameras (ZED X, ZED X One):
- [required]
/tmp:/tmp - [required]
/var/nvidia/nvcam/settings/:/var/nvidia/nvcam/settings/ - [required]
/etc/systemd/system/zed_x_daemon.service:/etc/systemd/system/zed_x_daemon.service
- [required]
Optimize your Image Size
Docker images can grow very large and become a problem when pulling over the network or pushing to devices with limited storage (such as the NVIDIA® Jetson™ Orin™ Nano). Here are a few tips to keep your image size down:
- Minimize the number of
RUNcommands. Each command adds a layer to the image, so consolidatingRUNinstructions reduces the number of layers in the final image. Note that layers are reusable and are not pushed or pulled if they did not change. - Use
--no-install-recommendswhen installing packages withapt-get installto skip optional packages and save disk space. - Remove tarballs and other archive files that were copied during installation. Each layer is stacked on top of the previous ones, so files that are not removed within a given
RUNstep remain in the final image even if they are deleted in a laterRUNstep. - Similarly, clean the package lists downloaded by
apt-get updateby removing/var/lib/apt/lists/*in the sameRUNstep. - Create separate images for development and production. Production images should not include all of the libraries and dependencies pulled in by the build.
- Use multi-stage builds and push only your
prodimage.
Host your Docker Image
Now that you have created your image, you need to share it on a registry so it can be downloaded and run on any destination machine. A registry is a stateless, server-side application that stores Docker images and lets you distribute them.
Use the Docker Hub Registry
By default, Docker provides an official free-to-use registry, Docker Hub, where you can push and pull your images. For example, at StereoLabs the ZED SDK Docker images are built automatically from the zed-docker GitHub repository and pushed to the StereoLabs Docker Hub repository.
There are situations where you do not want your image to be publicly available. In that case, you can create your own private Docker registry. You can get private repositories from Docker, or from many other third-party providers.
Use a Local Registry Server
For local development, if your host and target machines are on the same network, you can set up a local registry server and push your images there.
For more information on deploying your own registry server, refer to the Docker Registry documentation.
Save and Load Images as Files
Lastly, you can also export and load your Docker image as a file.
To export a Docker image, simply use:
On the destination machine, load the Docker image with:

