StanagProcessor as a Docker container

Docker

This section provides instructions for deploying and running the software as a Docker container.

Prerequisites

Ensure Docker is installed on your Linux system. Refer to the Docker documentation for installation instructions specific to your Linux distribution.
If you prefer managing your Docker deployment with Docker Compose, ensure that Docker Compose is also installed.

On Windows, you can use the Docker Desktop application, WSL2 or VM to manage your Docker environment.

Docker

Before running the StanagProcessor container, you need to create a named Docker volume to store the database and log files. Named volumes persist data even when the container is stopped or removed.

To create the volume, run the following commands:

docker volume create stprocessor-data
  • stprocessor-data: Volume for storing the database and logs.

Once the volume is created, you can start the StanagProcessor container. Use the following command to run the container in detached mode, with the volume mounted and the network set to host mode:

docker run -it --rm --network=host \
  -v stprocessor-data:/app/data \
  impleo/stanagprocessor:1.0.0 -addr 0.0.0.0:8400
  • --network=host: Uses the host’s network, allowing the container to listen on all network interfaces of the host.
  • -v stprocessor-data:/app/data: Mounts the database volume to /app/data/data.db inside the container.

  • -addr 0.0.0.0:8400: The container listens on all interfaces on port 8400.

After running this command, the StanagProcessor service will be accessible at http://localhost:8400.

Docker Compose

Create a docker-compose.yml file in your preferred directory and define the services required for running the StanagProcessor.

Example docker-compose.yml:

services:
  stanagprocessor:
    image: impleo/stanagprocessor:1.0.0
    container_name: stanagprocessor
    network_mode: host   
    volumes:
      - stprocessor-data:/app/data
#    devices:
#      - /dev/video0:/dev/video0
    restart: unless-stopped
    command: -addr 0.0.0.0:8400

volumes:
  stprocessor-data:

Note: You should only map existing video devices to the container. If device is not available, the container will not start.

Video capture devices

To access the host webcam from a Docker container on Ubuntu, follow these steps:

  • Identify the webcam device:

On the host Ubuntu system, run the following command to find your webcam device:

ls -l /dev/video*

This will typically show your webcam as /dev/video0 or a similar device name

  • Run the Docker container with device access:

Use the --device flag when running your Docker container to give it access to the webcam:

docker run -it --network=host --device=/dev/video0:/dev/video0 --name stprocessor impleo/stanagprocessor:1.0.0 -addr 0.0.0.0:8400
  • Set up proper permissions:

If you encounter permission issues, you may need to add your user to the video group on the host system:

sudo usermod -aG video $USER

Then, restart your system or log out and log back in for the changes to take effect

If you're using Docker Compose, add the device mapping to your docker-compose.yml file:

services:
  stanagprocessor:
    image: impleo/stanagprocessor:1.0.0
    container_name: stprocessor
    network_mode: host   
    volumes:
      - stprocessor-data:/app
    devices:
      - /dev/video0:/dev/video0
    restart: unless-stopped
    command: -addr 0.0.0.0:8400

volumes:
  stprocessor-data:

For more complex setups or if you need access to multiple devices, you can use the --privileged flag, but be cautious as this gives the container full access to the host system