Skip to content

How To: Use Basler USB Cameras in a Docker Container#

The following article assumes that you are familiar with Docker installation and Docker commands.

Here is the configuration we are using:

  • Host OS: Ubuntu 20.04 and pylon 6.2
  • Guest OS: Ubuntu 20.04 and pylon 6.2

Proceed as follows:

  1. Create a directory of your choice on your host system, e.g., /home/user/dockerImage.
  2. Copy the Docker file there.
  3. Download and save a pylon Debian package into this directory.
  4. Open a terminal, head to the directory and execute the following command to generate a Docker image based on public Ubuntu 20.04 image:

    sudo docker build -t pylon

    This command also installs pylon in Docker image.

  5. Run fresh built image using the following command:

    sudo docker run -ti -v '/dev/bus/usb':'/dev/bus/usb' --privileged -e DISPLAY=$DISPLAY -v '/tmp/.X11-unix':'/tmp/.X11-unix' pylon

You will now see all Basler USB cameras connected to the host system in the Docker container as well.

You can then carry on your work. Run lsusb or build the grab sample and run it.

Back to Knowledge Articles