I made a python docker that runs windows so that I can use .NET with no problem. I`m trying to use this docker to control some devices connect to my computer via USB, such as some stepper motors and receive information from a detector. How do I make them visible from inside the docker container?
Hi,
you need to mount the USB-devices into docker. Take a look at https://docs.sevenbridges.com/docs/mount-a-usb-drive-in-a-docker-container to get an idea on how to do that.
But i’m using Windows Container, in this link they only show for Linux containers
Here are the DOCKERFILE code and the code i use to open python inside this docker.
DOCKERFILE:
FROM python:3.6
RUN pip install jupyter
RUN pip install numpy
RUN pip install PyVISA
RUN pip install PyQt5
RUN pip install pymeasure
RUN pip install pandas
RUN pip install matplotlib
RUN pip install sockets
RUN pip install nidaqmx
RUN pip install pythonnet
RUN mkdir /notebooks
EXPOSE 8888
VOLUME C:/Users/Taper/Docker/notebooks
Code to open python jupyter notebook:
docker run --name test02 -it -p 8888:8888 -d -v ${PWD}\notebooks:C:\notebooks test02_image
docker start test02
docker exec -it test02 jupyter notebook --ip 0.0.0.0
I have 5 USB Devices to control from this Windows Container (Note that both the host and the container are running windows), the devices are 4 stepper motors and a laser.
I’m trying to use the --device flag but I don’t know how to use it.
Hi,
I made some investigations last night and is seems like the Windows Container over Hyper-V does not support USB-passthrough. I managed to get it through when using Linux Containers on my Windows 10, but not when using Windows Containers.
I have no trouble passing USB devices to an instance that is created with Docker Machine, but that is a pure VM so it uses the “old” way to access host devices.
Only way I could connect my Windows Container to my USB Device was to use USB/IP.
How do you use Docker Machine on Windows? I’ve never used it. How do you pass USB to the Docker Machine?
Hi,
sorry, been away. You find everything about Docker Machine at https://docs.docker.com/machine/overview/.
- Install Docker Machine
- Install VirtualBox
- Run the commands
I’m having problems running my original image in the docker-machine, it’s a windows based image.
How do I make docker-machine run windows?
You don’t, it will spin up a virtual linux host.
I know this is an old thread, but you said you were able to use USB devices when using linux containers on Windows host machine but to my knowledge this is not possible. Are you able to provide any documentation or direction on how you achieved this?
I don’t know the answer, but in case you don’t get an answer I would point out that this topic was about Docker Machine and we use Docker Desktop recently. If you do it as well, that could be a difference. I don’t remember how Docker Machine worked exactly to be honest. If you are using Docker Desktop, you are probably using it with the WSL2 backend. If that’s the case, this is what I found: