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:
- 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. - 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.