Docker Container Does Not See Serial Port Device

I am trying to start a docker container with serial port access on the host.

Here is what I did:

  • I used a mac
  • Drivers installed on the host ( http://www.prolific.com.tw/US/ShowProduct.aspx?p_id=229&pcid=41 )
  • Connected device
  • Launched ls/dev/t* which returned /dev/tty.usbserial - this worked
  • docker run -it --privileged -v/dev: /dev node:4.4.0/bin/bash container, docker run -it --privileged -v/dev: /dev node:4.4.0/bin/bash , and then ls/dev/t* inside the container that didn't return the /dev/tty.usbserial device ...

I played a lot with different variations of the parameters, but did not find a working one :)

Also, the --device flag --device not suit me, since the device may be reconnected, and the name may differ from /dev/tty.usbserial .

+6
bash docker device serial-port usb
May 13, '16 at 15:24
source share
2 answers

You can check if the script described in the section “ Notification of new USB devices in the dock container ” (from Guido gdiepen - gdiepen ) can gdiepen .

It also launches its container with the --privileged argument to allow it access to devices. And it mounts the host /dev/bus/usb /dev/bus/usb to the /dev/bus/usb directory inside the container with the argument -v/dev/bus/usb: /dev/bus/usb when the specified container starts.

The script uses both inotifywait and lsusb to wait for the devices to be (not) connected, and to check whether this device was of interest to us.

inotifywait will continue to listen to inotifywait dev/bus/usb create / delete inotifywait and will execute commands whenever the inode corresponding to the corresponding device has just been created.

See Also, as soon as you find a connected USB device, How to get a connection between the bus and the device for /dev/ttyUSB (not applicable to Docker, but still relevant).

+2
May 24 '16 at 7:00
source share

As @pgayvallet pointed out on GitHub :

Since the daemon runs inside the virtual machine in Docker Desktop, it is actually not possible to share the mac host device with the container inside the virtual machine , and this will certainly never be possible.

0
Jan 23 '19 at 16:10
source share



All Articles