How to add a windows host usb device to the docker container - docker

I need to access the USB device from the Docker container that ran on the Windows host (WSL2). The device is a USB flash drive with the content (files) and serial number. How to mount it and access the data?
I've tried --device=/dev/bus/usb:/dev/bus/usb and usbipd but it doesn't work.

Related

How to give a docker container access to an unmounted USB device

I have a Realtek RTL2832U dongle for software defined radio (SDR). I would like to give my Docker container access to the device.
The solutions I have found so far:
The --privileged flag for docker run. Problem: insecure
The --device flag for docker run. Problem: the Realtek dongle isn't a mounted USB device, so I can't find a device path (i.e. /dev/ttyUSB0) by running df -h. However, the device does show up when I run lsusb, as Bus 003 Device 027.
My questions:
Is it possible to mount a usb device that isn't a data storage device? If so, how would I do that?
If not, how can I give my docker container access to this usb device?

routing broadcast UDP in/out of Docker for Mac container

I want to run an application (the OLA server, olad) inside a container under Docker for Mac. (Version 18.06.1-ce-mac73 on Mojave, all up-to-date.) The particular OLA configuration I am using (for the Art-Net protocol) works by sending and receiving UDP broadcast data over port 6454 on a particular physical ethernet interface on the host, which is in turn connected to an external device under control. Normally, when starting the olad server, one specifies the interface or IP address on which it should send/receive the broadcast messages.
My struggle is getting the UDP messages to and from the interface from inside the container. I don't appear to have access to that physical interface or network inside the Docker for Mac container, even if I run with --network host. My understanding is that this is because of a quirk of the way Docker for Mac is implemented, with an extra VM between my container and the hardware. That VM sees the hardware, but I don't.
Simply running the docker instance with -p 6454:6454/udp doesn't work, either, maybe unsurprisingly. I could see where that might allow incoming traffic to the container to find its way to the server, but the server inside still can't find the outside network/device in the other direction. And I'm not sure how OSX would necessarily get that data from the interface to the docker bridge anyway.
How can I get direct, bidirectional access to that interface or network from inside the container? Or if I cannot, is there some kind of workaround, maybe via socat where I could tunnel that network in through a Unix socket that is shareable between host and container?

Access a USB device (not a memory stick) in a Docker container from a macOS host

Is it possible to access a USB device (which is not a memory stick) in a Docker container?
I've come across the --—privileged and --device options which I guess would work if I had a Linux host, but they don't seem to work in macOS where USB devices don't show up in /dev.
It looks like docker-machine + VirtualBox is the way to go. I documented the steps I took in the blog post How to use a USB device in a Docker container on Mac.

Access devices on local network when running Docker for Mac

I have some smart wifi devices on my network I can see from a script on my Mac. But running the same script from within a Docker container those devices are not visible.
I assume this is related to Docker for Mac's inability to connect to the host's network using --network host or network_mode: host. I also assume this issue wouldn't exist on a Linux machine but I don't have one to test on.
What is the workaround?
Edit:
Confirmed this worked fine when running inside an Ubuntu virtualbox, but I'd really not have to develop inside it.
If you start the container with network option as host, the container will share the network stack of the host. Thus any device reachable from you host should be reachable by the container.
docker run --network host ...
Adding containers to a network would allow them to communicate with each other but if you want to access other services running on host then host.docker.internal (from 18.03+). I had to do the same in a mac mini setup to access external service.
[https://docs.docker.com/docker-for-mac/networking/]
If you have to access a service on another host then you can setup an nginx server on the docker host and a proxy pass rule to direct it to the remote service.

How to get the IP addresses of a device using its MAC id from inside a Docker Container?

Is there a way to get the IP address of a device (running on my host machine) if I know its MAC address from inside a Docker Container? I have already tried all the solutions suggested in here.
1) Trying to broadcast ping and using arp -a only gives the Gateway address, since docker is running inside a subnet.
2) Using nmap I cannot verify the MAC, I could only see if there is a live host in that address.
I tried the above by running docker in --privileged mode and still the results are the same.

Resources