1

I am trying to mount USB device so that docker can access host USB devices from the containers. I followed the Dynamically access USB devices. I have few doubts here:

  1. My container is already existing so as per my understanding docker run command will create new container but I want to use the existing container.
  2. As a try, I proceeded with creating new container following the method given in 1 but even then USB device was not detected when I do lsblk inside the container.

I have used the command:

docker run --name testswu -it -v /dev:/dev --device-cgroup-rule='c 180:* rmw' --device-cgroup-rule='c 188:* rmw' --device-cgroup-rule='c 81:* rmw' --device-cgroup-rule='c 4:* rmw' --device-cgroup-rule='c 13:* rmw' --device-cgroup-rule='c 199:* rmw' --device-cgroup-rule='c 226:* rmw' ubuntu:20.04

I am using device major number from Device major number and added rules to start container as:

--device-cgroup-rule='c major_number:* rmw'

Can someone please let me know what I am missing here so that I can use existing container to mount and access host USB devices?

Docker running on Windows machine P.S. I am using Docker with Linux containers and also WSL2 enabled so I cannot use Shared Drives/File Sharing option in docker settings.

Update

As a workaround, I have switched to virtual box with Ubuntu 20.04. Now I can access host USB devices and play with them.

Sourabh_Hegde
  • 25
  • 2
  • 7
  • Deleting and recreating containers is extremely routine. If your current container has the wrong settings, delete it and recreate it. That having been said, a design goal of Docker is to prevent applications from directly accessing the host hardware, and you might find this easier to do running your program directly on the host. – David Maze Dec 14 '21 at 12:07
  • Hi David, thanks for the update. Is there any other way to access host USB devices? – Sourabh_Hegde Dec 14 '21 at 12:53
  • 2
    Hi David, I have added 'Update' to my original question. Can you please upvote the question so that it's no longer negative voted question? Thanks in advance. – Sourabh_Hegde Dec 16 '21 at 10:21

0 Answers0