Connecting to camera(s) in Docker

This page describes how you can connect to one or multiple cameras with custom IP addresses in Docker.

Note

Make sure you have configured your Network Configuration on the host machine before continuing.

Docker uses the bridge network driver by default, which does not allow multicast traffic. This means multicast DNS (mDNS) network discovery is unavailable, and only cameras with default IP 172.28.60.5 can be discovered without further configuration. There are two ways to work around this.

A simple solution is to expose the host network to the Docker container. This can be done by enabling --network=host when running the Docker container, like

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

where <image> is the Docker image you are launching the container from. Note that this will expose all host network interfaces to the container.

Zivid SDK can search for specific IP addresses instead of using mDNS by using a file Cameras.yml. Check out Cameras.yml and how to restrict discoverable cameras to read more about how this works. Add the following to your Dockerfile to discover cameras with non-default IPs.

ENV ZIVID_CONFIG=/root/.config/Zivid/API/Cameras.yml
RUN mkdir --p $(dirname $ZIVID_CONFIG)
RUN echo "__version__: 1"                   >> $ZIVID_CONFIG
RUN echo "Cameras:"                         >> $ZIVID_CONFIG
RUN echo "    NetworkCameras:"              >> $ZIVID_CONFIG
RUN echo "        - NetworkCamera:"         >> $ZIVID_CONFIG
RUN echo "            Host: 172.28.60.5"    >> $ZIVID_CONFIG
RUN echo "        - NetworkCamera:"         >> $ZIVID_CONFIG
RUN echo "            Host: 172.28.60.6"    >> $ZIVID_CONFIG
RUN echo "        - NetworkCamera:"         >> $ZIVID_CONFIG
RUN echo "            Host: 172.28.60.7"    >> $ZIVID_CONFIG

Change the Host field to discover the camera with your specific IP address, or add another NetworkCamera. Build the Docker image again for the changes to take place.

Verify that you can discover all connected cameras in the Docker container by running

ZividListCameras