allfro / device-mapping-manager

52 stars 8 forks source link

I'm having difficulty understanding how to use this. #11

Closed gitdeath closed 9 months ago

gitdeath commented 9 months ago

I'm having a real challenge trying to understand how to use this capability.

yml in use

version: "3.8"

services:
  dmm:
    image: docker
    entrypoint: docker
    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
      ndouba/device-mapping-manager
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock

If I run a local compose I get this error, which is the same error I get if I try to run a stack.

location# docker compose -f dmm.yml up
[+] Running 1/1
 ✔ dmm Pulled                                                                                                                                                                                                       1.7s
[+] Running 2/2
 ✔ Network compose_files_default  Created                                                                                                                                                                           0.4s
 ✔ Container compose_files-dmm-1  Created                                                                                                                                                                           1.1s
Attaching to compose_files-dmm-1
compose_files-dmm-1  | Unable to find image 'ndouba/device-mapping-manager:latest' locally
compose_files-dmm-1  | docker: Error response from daemon: Encountered remote "application/vnd.docker.plugin.v1+json"(plugin) when fetching.
compose_files-dmm-1  | See 'docker run --help'.
compose_files-dmm-1 exited with code 125

I've tried with the plugin installed and not installed it doesn't seem to make a difference.

ID             NAME                                   DESCRIPTION                                  ENABLED
966a804cd0fc   ndouba/device-mapping-manager:latest   A device mapping plugin for swarm clusters   true

Just doing a pull results in:

location$ docker pull ndouba/device-mapping-manager:latest
Error response from daemon: Encountered remote "application/vnd.docker.plugin.v1+json"(plugin) when fetching
dracossan commented 9 months ago

Hi,

this image: ndouba/device-mapping-manager does not exist. you have to compile it locally, before run the docker compose.

have a look in the build.sh script: https://github.com/allfro/device-mapping-manager/blob/master/build.sh

Attaching to compose_files-dmm-1
compose_files-dmm-1  | Unable to find image 'ndouba/device-mapping-manager:latest' locally

if you have a local image registry:

git clone https://github.com/allfro/device-mapping-manager.git
cd device-mapping-manager
docker buildx build --push --platform linux/amd64 --tag my.registry.local:5000/device-mapping-manager .

and the compose I use. take note i deploy the image in global mode for all my Swarm node. It's not mandatory, could be deploy only on 1 node, but my case require for all.

version: "3.9"

services:
  dmm:
    image: docker
    entrypoint: docker
    command: |
      run 
      -i
      --rm 
      --name device-manager 
      --privileged 
      --cgroupns=host 
      --pid=host 
      --userns=host 
      -v /sys:/host/sys 
      -v /var/run/docker.sock:/var/run/docker.sock 
      my.registry.local:5000/device-mapping-manager
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    deploy:
      mode: global
      placement:
        max_replicas_per_node: 1
        constraints: [node.platform.os == linux]
      update_config:
        parallelism: 1
        delay: 10s
      restart_policy:
        condition: any
        delay: 10s
        max_attempts: 0
        window: 10s

once deploy, have a look on the log file of the DMM container, you will see when the other container need to access to a device like /dev/dri for example, the CGROUP will be changed.

gitdeath commented 9 months ago

Thank you. I'm running now.