Skip to content

Support for managing containers and devices with labels #18

@cdalvaro

Description

@cdalvaro

I've seen that the service watches all volumes in every container.

It would be great if there was a method to filter containers and volumes with labels.

For example, you could start the device-mapping-manager service only looking for services with the label enabled by passing some environment variable like: DMM_LABEL_ENABLE=true

services:
  dmm:
    image: docker
    entrypoint: docker
    deploy:
      mode: global
    command: |
      run 
      -i
      --name device-manager 
      --restart always 
      --privileged 
      --cgroupns=host 
      --pid=host 
      --userns=host 
      -v /sys:/host/sys 
      -v /var/run/docker.sock:/var/run/docker.sock 
      ghcr.io/allfro/allfro/device-mapping-manager:latest
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    environment:
      DMM_LABEL_ENABLE: 'true'

Then, for a container to be watched, you could set the following labels:

labels:
  com.allfro.device-mapping-manager.enable: 'true'
  com.allfro.device-mapping-manager.regexp: '/dev/*' # Optional. If not defined, then all volumes

That way, DMM will look for those containers with the label enabled, and will use the regexp pattern to filter only those volumes (when available).

Some services that make use of this technique are:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions