title: Docker Swarm Generic Device Resource Connection
body: <p><strong>Docker Help Request</strong>: I am trying to connect a container within our Swarm to a device in <code>/dev</code>. The connection works correctly via device mapping when running in a docker container, however we are unable to connect to the device within our Swarm node.</p>
  
  <p>The device happens to be graphics hardware to use vaapi drivers with our Gstreamer pipeline, and is located here: <code>/dev/dri/renderD128</code>, but this is a generic question for connecting to any device from a container in a swarm.</p>
  
  <p><strong><em>I am looking for advice on what it would look like to map to our device through Swarmkit Generic Resources.</em></strong></p>
  
  <p>There is discussion available regarding Swarmkit and graphics hardware including:</p>
  
  <ul>
  <li>(Issue) Add Support for Swarmkit Generic Resources #33439:
  <a href="https://github.com/moby/moby/issues/33439" rel="nofollow noreferrer">https://github.com/moby/moby/issues/33439</a></li>
  <li>(Merged PR) Add Generic Resources #5416: <a href="https://github.com/docker/docker.github.io/pull/5416" rel="nofollow noreferrer">https://github.com/docker/docker.github.io/pull/5416</a></li>
  </ul>
  
  <p>But, I have been unable to distill these into a solution.</p>
  
  <p>One docker run command that successfully connects to this device when <em>NOT</em> running in the swarm looks like this: </p>
  
  <pre><code>docker run -ti \
  -e XDG_RUNTIME_DIR=/tmp \
  --device=/dev/dri/card0:/dev/dri/card0 \
  --device=/dev/dri/renderD128:/dev/dri/renderD128 \
  -v $XDG_RUNTIME_DIR/$WAYLAND_DISPLAY:/tmp/$WAYLAND_DISPLAY \
  &lt;docker-image&gt; bash
  </code></pre>
  
  <p>But again, this is a generic question for containers, swarms, and device mapping in general, and is not related to this particular device.</p>
  
  <p>We are using docker compose file version 3, and have tried the "<code>device</code>" option which fails as expected:
  <a href="https://docs.docker.com/compose/compose-file/#devices" rel="nofollow noreferrer">https://docs.docker.com/compose/compose-file/#devices</a></p>
  
  <blockquote>
    <p>"This option is ignored when deploying a stack in swarm mode with a
    (version 3) Compose file."</p>
  </blockquote>
  
  <p>I am grateful for your help.</p>