StreamMonitor 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.

Running Docker on a machine that is not connected to the internet

If you are not connected to the internet, you can download the Docker image from the Docker Hub and store it locally.
More information on Docker offline

Docker

Before running the StreamMonitor 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 streammonitor-data
  • stream-monitor-data: Volume for storing the database and logs.

Once the volume is created, you can start the StreamMonitor 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 stream-monitor-data:/app/data \
  impleo/stream-monitor: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 stream-monitor-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 StreamMonitor 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 StreamMonitor.

Example docker-compose.yml:

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

volumes:
  stream-monitor-data:

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 stream-monitor impleo/stream-monitor: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:
  stream-monitor:
    image: impleo/stream-monitor:1.0.0
    container_name: stream-monitor
    network_mode: host   
    volumes:
      - stream-monitor-data:/app
    devices:
      - /dev/video0:/dev/video0
    restart: unless-stopped
    command: -addr 0.0.0.0:8400

volumes:
  stream-monitor-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