Install Zivid in Docker

The instructions for installing Zivid software in a Docker container depend on your operating system and hardware. Follow the instructions that apply to your setup.

On Windows, Docker Desktop runs Linux containers through the WSL backend.

The Intel path uses the OpenCL compute backend. On WSL, OpenCL is not available to Docker containers, so the OpenCL backend cannot be used on Windows. Use the CUDA backend instead, as shown in the NVIDIA tab. This requires an NVIDIA GPU, so running Zivid in Docker on Windows is not possible with an Intel GPU.

On WSL, the NVIDIA GPU driver exposes CUDA to Docker containers, so the CUDA backend is used.

Prerequisites

  • Docker Desktop with the WSL 2 based engine enabled.

  • An NVIDIA GPU with a recent driver, verified by running nvidia-smi.

Download the following Dockerfile for a minimal Docker image using Zivid software on Ubuntu 24.04.

FROM nvidia/cuda:12.5.1-runtime-ubuntu24.04

RUN apt-get update && apt-get install --assume-yes \
    wget

ENV NVIDIA_VISIBLE_DEVICES all
ENV NVIDIA_DRIVER_CAPABILITIES compute,utility

RUN wget --quiet \
    https://downloads.zivid.com/sdk/releases/2.18.0+1b44dbef-1/u24/amd64/zivid-cuda_2.18.0+1b44dbef-1_amd64.deb \
    https://downloads.zivid.com/sdk/releases/2.18.0+1b44dbef-1/u24/amd64/zivid-tools_2.18.0+1b44dbef-1_amd64.deb \
    https://downloads.zivid.com/sdk/releases/2.18.0+1b44dbef-1/u24/amd64/zivid-genicam_2.18.0+1b44dbef-1_amd64.deb

RUN apt-get update
RUN apt-get install ./*.deb --assume-yes && rm ./*.deb

Navigate to the directory where you placed the Dockerfile, and build and run the container from a Windows terminal by running

docker build -t <image> .
docker run --interactive --tty --gpus all <image>

where <image> is your chosen name of the image, e.g. zivid. The image already targets the CUDA backend, so no further configuration is needed.

To verify that the Zivid SDK works, connect to the camera by its IP address. Docker Desktop runs containers in the WSL virtual machine, which does not reach cameras on the LAN through mDNS discovery, so ZividListCameras will not find the camera on Windows. A direct connection by IP address does work.

Create a small program that connects to the camera, replacing 172.28.60.5 with your camera’s IP address.

#include <Zivid/Zivid.h>
#include <iostream>

int main()
{
    Zivid::Application zivid;
    auto camera = zivid.connectCamera(Zivid::CameraAddress{ "172.28.60.5" });
    std::cout << "Connected to " << camera.info().serialNumber() << std::endl;
}

Build and run it inside the container. If it prints the camera serial number, the Zivid SDK is working. See Connecting to camera(s) in Docker for more on connecting by IP address or hostname.

Note

A camera can only be connected to from one place at a time. Disconnect the camera in Zivid Studio, or any other application, before connecting from the container. Otherwise the connection times out waiting for the camera to respond.

Prerequisites

Intel GPU drivers should already be installed on the host machine if you are using Intel. If not, download and install Intel drivers.

Download the following Dockerfile for a minimal Docker image using Zivid software on Ubuntu 24.04.

FROM ubuntu:24.04

RUN apt-get update && apt-get install --assume-yes \
    wget \
    intel-opencl-icd

RUN wget --quiet \
    https://downloads.zivid.com/sdk/releases/2.18.0+1b44dbef-1/u24/amd64/zivid-opencl_2.18.0+1b44dbef-1_amd64.deb \
    https://downloads.zivid.com/sdk/releases/2.18.0+1b44dbef-1/u24/amd64/zivid-tools_2.18.0+1b44dbef-1_amd64.deb \
    https://downloads.zivid.com/sdk/releases/2.18.0+1b44dbef-1/u24/amd64/zivid-genicam_2.18.0+1b44dbef-1_amd64.deb

RUN apt-get update
RUN apt-get install ./*.deb --assume-yes && rm ./*.deb

Navigate to the directory where you placed the Dockerfile, and build and run the container by running

sudo docker build -t <image> .
sudo docker run --interactive --tty --device=/dev/dri --network=host <image>

where <image> is your chosen name of the image, e.g. zivid. You should now be in an interactive session on Ubuntu with Zivid installed. The --network=host argument lets the container discover cameras on the host network.

First, install NVIDIA drivers on the host machine if they are not installed. Then install the NVIDIA Container Toolkit on the host.

curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \
&& curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \
    sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
    sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list \
&& \
    sudo apt-get update

sudo apt-get install -y nvidia-container-toolkit

Then configure Docker to use the NVIDIA Container Runtime.

sudo nvidia-ctk runtime configure --runtime=docker

Restart the Docker daemon.

sudo systemctl restart docker

You should now be able to access your NVIDIA GPU through Docker. Download the following Dockerfile for a minimal Docker image using Zivid software on Ubuntu 24.04.

FROM nvidia/cuda:12.5.1-runtime-ubuntu24.04

RUN apt-get update && apt-get install --assume-yes \
    wget

ENV NVIDIA_VISIBLE_DEVICES all
ENV NVIDIA_DRIVER_CAPABILITIES compute,utility

RUN wget --quiet \
    https://downloads.zivid.com/sdk/releases/2.18.0+1b44dbef-1/u24/amd64/zivid-cuda_2.18.0+1b44dbef-1_amd64.deb \
    https://downloads.zivid.com/sdk/releases/2.18.0+1b44dbef-1/u24/amd64/zivid-tools_2.18.0+1b44dbef-1_amd64.deb \
    https://downloads.zivid.com/sdk/releases/2.18.0+1b44dbef-1/u24/amd64/zivid-genicam_2.18.0+1b44dbef-1_amd64.deb

RUN apt-get update
RUN apt-get install ./*.deb --assume-yes && rm ./*.deb

Navigate to the directory where you placed the Dockerfile, and build and run the container by running

sudo docker build -t <image> .
sudo docker run --interactive --tty --device=/dev/dri --gpus=all --network=host <image>

where <image> is your chosen name of the image, e.g. zivid. You should now be in an interactive session on Ubuntu with Zivid installed. The --network=host argument lets the container discover cameras on the host network.

To verify that the Zivid SDK works, run the following inside the container.

ZividListCameras

If there are no errors then the Zivid SDK is working within the Docker container.

Note

You will only be able to find a camera with default static IP 172.28.60.5. To connect to one or multiple cameras with a custom IP, follow Connecting to camera(s) in Docker.

Prerequisites

  • Docker Engine

  • JetPack, which bundles the NVIDIA Container Runtime.

Note

Because the NVIDIA Container Runtime is bundled with JetPack, you do not need to install the NVIDIA Container Toolkit.

The Dockerfiles provided on this page target x86 Ubuntu and are not compatible with Jetson, which is ARM64.

Choose the base image based on your JetPack version:

  • JetPack 5 and JetPack 6: use NVIDIA L4T Base (nvcr.io/nvidia/l4t-base). Select the tag that matches your installed JetPack, which you can find by running cat /etc/nv_tegra_release (for example, R36 (release), REVISION: 3.0 corresponds to tag r36.3.0).

  • JetPack 7 and later: use the same NVIDIA CUDA containers (nvcr.io/nvidia/cuda) as the NVIDIA tab.

A minimal Dockerfile looks like this, where <base-image> is the base image chosen above.

FROM <base-image>

RUN apt-get update && apt-get install --assume-yes \\
    wget

RUN wget --quiet \\
    https://downloads.zivid.com/sdk/releases/2.18.0+1b44dbef-1/u22/arm64/zivid-cuda_2.18.0+1b44dbef-1_arm64.deb \\
    https://downloads.zivid.com/sdk/releases/2.18.0+1b44dbef-1/u22/arm64/zivid-tools_2.18.0+1b44dbef-1_arm64.deb \\
    https://downloads.zivid.com/sdk/releases/2.18.0+1b44dbef-1/u22/arm64/zivid-genicam_2.18.0+1b44dbef-1_arm64.deb

RUN apt-get update
RUN apt-get install ./*.deb --assume-yes && rm ./*.deb

Match the Ubuntu version in the package URLs (u22 or u24) to your JetPack version, as listed in Install Zivid on Jetson Linux.

Run the container by running

sudo docker run --interactive --tty --runtime=nvidia --gpus=all --network=host <image>

where <image> is your chosen name of the image, e.g. zivid. The --network=host argument lets the container discover cameras on the host network.

To verify that the Zivid SDK works, run the following inside the container.

ZividListCameras

If there are no errors then the Zivid SDK is working within the Docker container.

Version History

SDK

Changes

2.18.0

Added support for running Zivid in Docker on Windows, through the WSL backend with the CUDA compute backend.