MATRIX VISION - mvBlueCOUGAR-X/-XD Technical Documentation
Using GigE Vision™ Devices In A Docker Container

When developing machine vision applications using Docker containers, chances are that you would like to access GigE Vision™ devices inside the container. With the mvIMPACT Acquire driver stack this can be achieved fairly easy and this chapter will show you how to build a basic Docker container where you can use GigE Vision™ devices. The current sample Docker container runs on a native Linux machine.

Note
The following chapter is documented only for a native Linux host system.

Host Preparation

Note
For this demo Docker container the operating system of the host machine is Linux.

The host network interface card has to be first configured for an optimized GigE Vision™ transmission: Checklist for Linux

Building A Docker Image

The following demo Dockerfile builds a basic Docker image based on a slim version of Debian, where the mvIMPACT Acquire GenTL driver package and its sample programs are installed. This Dockerfile can be used in many ways:

  • Use it directly to test your device in a Docker container.
  • Use it as a base image for your device applications.
  • Use it as an inspiration for building your own Dockerfile.

Before building the Dockerfile, please download the mvIMPACT Acquire GenTL driver installation files from MATRIX VISION GmbH website (https://www.matrix-vision.com/treiber-software.html) (user login is required):

  • The installation script: install_mvGenTL_Acquire.sh
  • The installation package: mvGenTL_Acquire-x86_64_ABI2-*.tgz (* should be replaced by the version number)

Create a directory called mvIMPACT_Acquire (as used in this demo Dockerfile) and move both installation files into this directory. In this example, both files are downloaded into the Downloads directory and the mvIMPACT_Acquire directory is created inside the Downloads directory:

$ cd ~/Downloads
$ mkdir mvIMPACT_Acquire
$ mv install_mvGenTL_Acquire.sh mvGenTL_Acquire-x86_64_ABI2-*.tgz mvIMPACT_Acquire/

Make the installation script install_mvGenTL_Acquire.sh executable:

$ cd mvIMPACT_Acquire
$ chmod a+x install_mvGenTL_Acquire.sh

Navigate back into the directory where mvIMPACT_Acquire resides (e.g. Downloads) and create your Dockerfile:

$ cd ~/Downloads
$ touch Dockerfile

Create the content of your Dockerfile. Our demo Dockerfile (for Linux x86_64) looks as follows:

# start with slim version of actual Debian
FROM debian:9-slim

ENV LC_ALL C
ENV DEBIAN_FRONTEND noninteractive

# entrypoint of Docker
CMD ["/bin/bash"]

# set environment variables
ENV TERM linux
ENV MVIMPACT_ACQUIRE_DIR /opt/mvIMPACT_Acquire
ENV MVIMPACT_ACQUIRE_DATA_DIR /opt/mvIMPACT_Acquire/data
ENV GENICAM_GENTL64_PATH /opt/mvIMPACT_Acquire/lib/x86_64
ENV GENICAM_ROOT /opt/mvIMPACT_Acquire/runtime
ENV container docker

# update packets and install minimal requirements
# after installation it will clean apt packet cache
RUN apt-get update && apt-get -y install build-essential && \
    iproute2 && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# move the directory mvIMPACT_Acquire with *.tgz and *.sh files to the container
COPY mvIMPACT_Acquire /var/lib/mvIMPACT_Acquire

# execute the setup script in an unattended mode
RUN cd /var/lib/mvIMPACT_Acquire && \
    ./install_mvGenTL_Acquire.sh -u && \
    rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
Note
In case of ARM architectures, all occurrences of "x86_64" in this demo dockerfile have to be replaced by the correct platform e.g. "arm64" and the install script to use will be install_mvGenTL_Acquire_ARM.sh then.

Finally, build a Docker image using this Dockerfile:

$ sudo docker build -t [image_name] .
Note
Please make sure to call docker build from within the directory where the Dockerfile resides. Note that Internet access is required for the docker build.

If built successfully, you will be able to see [image_name] being listed when calling:

$ sudo docker images

Starting The Docker Container

Though the Docker container is isolated from the host system, we can connect the container to the host network by using –net=host flag when starting the container:

$ sudo docker run -ti --net=host [image_name] /bin/bash

Validation

After starting the container the correct operation of GigE Vision™ devices can be validated by running one of the sample programs provided by the mvIMPACT Acquire (e.g. SingleCapture):

$ cd /opt/mvIMPACT_Acquire/apps/SingleCapture/x86_64
$ ./SingleCapture

If the attached GigE Vision™ device appears in the device list of the program's output, congratulations, you've managed to access GigE Vision™ devices in the container by using the mvIMPACT Acquire. Now you can use them inside the Docker container for your machine vision applications.