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
- Linux – instructions here
- macOS Sierra 10.12 and newer macOS releases – instructions here
- Windows 10 64 bit Pro, Enterprise or Education (1607 Anniversary Update, Build 14393 or later) – instructions here
- OLDER Windows and macOS versions (e.g. Windows 10 Home) – instructions here
Step 2 – Launch the Dragonfly Java App
Launch this command:
docker run -p HOST_PORT:CONTAINER_PORT -ti --mount source=VOLUME_NAME,target=/app --device=/HOST_USB_CAMERA_PATH:/CONTAINER_USB_CAMERA_PATH dragonflycv/dragonflyjava -s SITE_ID -u USERNAME -p PASSWORD -b CONTAINER_PORT
-p HOST_PORT:CONTAINER_PORTis 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.
-tijust displays the output of the what’s running in the container. This can be hidden by replacing it with
-tdwhich 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_NAMEwhich 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_PATHis 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
dragonflycv/dragonflyjavais 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!
EXAMPLE of call:
docker run -p 5000:5000 -ti --mount source=df5000,target=/app --device=/dev/video0:/dev/video0 dragonflycv/dragonflyjava -s SITE_ID -u USERNAME -p PASSWORD -b 5000
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.