allfro / device-mapping-manager

58 stars 9 forks source link

Looking for more in depth documentation #12

Open maxfield-allison opened 11 months ago

maxfield-allison commented 11 months ago

Hello and thank you for this project! I'm trying to deploy a usb device (google coral) to containers I will manually schedule on one node and I'm struggling to figure out exactly how to deploy this container so it will enable the containers to mount the USB devices. Could someone give me a quick and dirty run down?

allfro commented 10 months ago

all you have to do is run the dmm binary on the Docker node. It will do the rest for you.

dlasher commented 10 months ago

@maxfield-allison is not alone in his request. The directions are cryptic.

git clone check docker stack check

running? doesn't appear to be

root@docker1:/opt/device-mapping-manager# docker service ls ID NAME MODE REPLICAS IMAGE PORTS b6vz1recvga2 dmm_dmm replicated 0/1 docker:latest

logs whine about no local copy found.

dmm_dmm.1.6krxbuzea1t8@docker3    | Unable to find image 'ndouba/device-mapping-manager:latest' locally
dmm_dmm.1.6krxbuzea1t8@docker3    | docker: Error response from daemon: Encountered remote "application/vnd.docker.plugin.v1+json"(plugin) when fetching.
dmm_dmm.1.6krxbuzea1t8@docker3    | See 'docker run --help'.
dmm_dmm.1.300z9uoyuvgi@docker6    | Unable to find image 'ndouba/device-mapping-manager:latest' locally
dmm_dmm.1.300z9uoyuvgi@docker6    | docker: Error response from daemon: Encountered remote "application/vnd.docker.plugin.v1+json"(plugin) when fetching.
dmm_dmm.1.300z9uoyuvgi@docker6    | See 'docker run --help'.
dmm_dmm.1.rs3ednggca4m@docker3    | Unable to find image 'ndouba/device-mapping-manager:latest' locally
dmm_dmm.1.rs3ednggca4m@docker3    | docker: Error response from daemon: Encountered remote "application/vnd.docker.plugin.v1+json"(plugin) when fetching.
dmm_dmm.1.rs3ednggca4m@docker3    | See 'docker run --help'.
root@docker1:/opt/device-mapping-manager# docker service logs dmm_dmm
dmm_dmm.1.6krxbuzea1t8@docker3    | Unable to find image 'ndouba/device-mapping-manager:latest' locally
dmm_dmm.1.6krxbuzea1t8@docker3    | docker: Error response from daemon: Encountered remote "application/vnd.docker.plugin.v1+json"(plugin) when fetching.
dmm_dmm.1.6krxbuzea1t8@docker3    | See 'docker run --help'.
dmm_dmm.1.rs3ednggca4m@docker3    | Unable to find image 'ndouba/device-mapping-manager:latest' locally
dmm_dmm.1.rs3ednggca4m@docker3    | docker: Error response from daemon: Encountered remote "application/vnd.docker.plugin.v1+json"(plugin) when fetching.
dmm_dmm.1.rs3ednggca4m@docker3    | See 'docker run --help'.
dmm_dmm.1.300z9uoyuvgi@docker6    | Unable to find image 'ndouba/device-mapping-manager:latest' locally
dmm_dmm.1.300z9uoyuvgi@docker6    | docker: Error response from daemon: Encountered remote "application/vnd.docker.plugin.v1+json"(plugin) when fetching.
dmm_dmm.1.300z9uoyuvgi@docker6    | See 'docker run --help'.

So how about trying ./build.sh first?

Using default tag: latest
The push refers to repository [docker.io/ndouba/device-mapping-manager]
901db172cd65: Preparing
5af4f8f59b76: Preparing
denied: requested access to the resource is denied

assuming it doesn't want me pushing back to docker -- and it's supposed to create a local copy.. Is that the directions piece we're missing?

bsaint9 commented 9 months ago

I agree. The instructions for using this are not clear. I'm at the same place as @dlasher. Same steps, same errors. Any insights on how to get this working would be greatly appreciated.

Docker (25.0.3) Swarm running on 3 Ubuntu 22.04 VMs.

maxfield-allison commented 9 months ago

does this need to run on the docker nodes individually or as a swarm stack?

saumuresolutions commented 9 months ago

Hi all, I am struggling with the same issue so I started to debug. I went on Dockerhub and saw that the docker-compose.yaml points to a plugin and not a docker image. Did not manage to get the plugin to work. But I did find a working image in the release section of this repo. So to make it work, I simply changed the image in the docker-compose.yaml to: ghcr.io/allfro/allfro/device-mapping-manager:nightly

I then used the docker stack command from the README and it works perfectly.

n1nj4888 commented 8 months ago

Hi @saumuresolutions ! Which host operating system are you running on since I read somewhere that it didn’t work as swarm stack running on Ubuntu/Debian because of an apparmour issue?

saumuresolutions commented 8 months ago

@n1nj4888 I am running Ubuntu 22.04.3 LTS on one of my servers and Ubuntu 23.10 on the other. And using this compose snippet below works for me on both nodes so I haven't spent much effort trying to get the plugin working:

version: "3.8"

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
davidry commented 8 months ago

Try this as your docker-compose.yml:

  1. deploying smaller master image (alpinelinux/docker-cli) - reducing image from ~122MB down to ~49MB
  2. Starts new Docker image using nightly DMM image- (thanks @saumuresolutions for the working image!)
  3. on service termination, slave process is now also removed, allowing recreation of the service without errors

command to run: docker stack deploy dmm -c docker-compose.yml --prune

--- docker-compose.yml ---

version: '3.8'
services:
  dmm:
    image: alpinelinux/docker-cli
    deploy:
        mode: global
    entrypoint: docker
    command: |
        run 
        --rm
        -i
        --name device-manager
        --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:nightly
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock

DMM listens for new services and adds the CGroup Namespace. Simply put, the Hardware accelerated services must be started After DMM is operational

to allow hardware acceleration, you add the device as a volume. DMM will upgrade the container's permissions to be able to use the hardware when the service first starts.

example of a tdarr Swarm stack listed below. [example provides Intel IGPU hardware acceleration]

--- docker-compose-tdarr.yml ---

version: '3.8'
services:
  Tdarr_Web:
    container_name: TdarrWeb
    image: ghcr.io/haveagitgat/tdarr
    restart: unless-stopped
    ports:
      - 8265:8265
    environment:
      - TZ=$(TZ)
      - PUID=${PUID}
      - PGID=${PGID}
      - UMASK_SET=002
      - serverPort=8266
      - webUIPort=8265
      - internalNode=false
    deploy:
      mode: replicated
      placement:
        constraints:
          - "node.role==manager"
    volumes:
      - /dev/dri:/dev/dri
      - $(AppdataPath):/app/configs
      - $(MediaPath):/media

  Tdarr:
    container_name: Tdarr
    image: ghcr.io/haveagitgat/tdarr_node
    restart: unless-stopped
    environment:
      - TZ=Pacific/Auckland
      - PUID=0
      - PGID=0
      - UMASK_SET=002
      - serverIP=TdarrWeb
      - serverPort=8266
      - nodeID={{.Node.Hostname}}
    deploy:
      mode: global
    volumes:
      - /dev/dri:/dev/dri
      - tdarr:/app/configs
      - $(MediaPath):/media