Dragonfly works pretty well in a Docker container with a true native level of performances. A public Docker container with the Dragonfly Java App ready to run is available here.

Why Dragonfly inside Docker

These are the advantages of running the Dragonfly Java App in a Docker container:

  • There is no need for any installation or compilation as long as Docker is installed on the machine, a single command-line is enough to run the Dragonfly Java App (the Dragonfly Java App is downloaded at first start).
  • Your existing environment remains untouched as no installation of Dragonfly dependencies is required (there are all already inside the container).
  • The host machine can be any OS able to run Docker
  • It is very easy to run multiple instances of the Dragonfly Java App on the same machine. It is just required to start multiple containers.

How to run the Dragonfly Java App in Docker

Step 1 – Install Docker

Notes for Windows 10 Home:

  • If you encounter the following error message when first running the Docker Quick Start Terminal “Error creating machine: Error in driver during machine creation: Error setting up host only network on machine start: The host-only adapter we just created is not visible. This is a well known VirtualBox bug. You might want to uninstall it and reinstall at least version 5.0.12 that is is supposed to fix this issue Looks like something went wrong in step ´Checking if machine default exists´… Press any key to continue…”
    1. run Oracle VM VirtualBox (installed while installing the Docker Toolbox), and Check for Updates in the file tab.
    2. download and install the updates for Oracle VM VirtualBox.
    3. run again the Docker Quick Start Terminal as administrator.
  • The Docker Quick Start Terminal will output an IP address at the end of its configuration (e.g. “docker is configured to use the default machine with IP 192.168.99.100”). That is the IP address to be used inside the browser of your PC when launching the Dragonfly Web UI (e.g. http://192.168.99.100:HOST_PORT/).
  • The Docker Quick Start Terminal window MUST remain open while using the Dragonfly Java App!

Step 2 – Launch the Dragonfly Java App

Launch this command:

parameters:

  • -p HOST_PORT:CONTAINER_PORT is a port redirection between the host machine (HOST_PORT) and the container (CONTAINER_PORT). Basically the HOST_PORT should be the port at which you want to make the Dragonfly Java App available on the host machine and the CONTAINER_PORT should be the port on which the Dragonfly Java App is running.
  • -ti just displays the output of the what’s running in the container. This can be hidden by replacing it with -td which runs the container in background.
  • --mount source=VOLUME_NAME,target=/app. By default, a container does not store any data. This option allows to make a persistent storage for Dragonfly, for instance to keep the configuration, the tokens, the maps, etc. Here, we create a volume named VOLUME_NAME which stores all the data for this instance. Each time I open an instance with this storage space (VOLUME_NAME), the data stored inside this volume are restored. It is possible to create as many volumes as required, only the name has to be changed. Volumes can be inspected with the command docker volume inspect VOLUME_NAME, which also provides the real path of the volume on the host machine if you’d like to change the data inside it (for instance, to paste the camera calibration file).
  • --device=/HOST_USB_CAMERA_PATH:/CONTAINER_USB_CAMERA_PATH is a “device forwarding”. Basically the stream of the USB camera physically connected to the host machine (and available at the path /HOST_USB_CAMERA_PATH) is made available to the Dragonfly Java App running inside the container (at the path /CONTAINER_USB_CAMERA_PATH).
  • dragonflycv/dragonflyjava is just the name of our Dragonfly image. It is available on the Docker Hub, so if not existing locally Docker will automatically download it and create a container with it.
  • -s SITE_ID – Accuware siteID of the user.
  • -u USERNAME – Accuware username of the user.
  • -p PASSWORD – Accuware password of the user.
  • -b CONTAINER_PORT – port on which the Dragonfly Java App is running. It must be equal to the CONTAINER_PORT value set in the first parameter!

EXAMLE of call:

NOTES:

  • on Windows 10 (all versions) it is apparently not possible to forward a USB device from a Windows host to a container. Thus, the --device=/dev/video0:/dev/video0 option won’t work, and it is not possible to directly use a USB camera with Dragonfly running in a container. However, it should be possible to stream the camera locally from the host to the container, for instance using VLC to stream from the host and a gstreamer pipeline to get the stream in Dragonfly.

Step 3 – Launch the Dragonfly Web UI

To open the Dragonfly Web UI launch a browser and type the URL http://localhost:HOST_PORT/. When the Dragonfly Java Application is terminated, for instance using the Terminate button inside the Web UI, the container automatically closes after 20 seconds.