How Do I Pass Through A USB Device To A Docker Container?


Recommended Posts

Hi,

Im also very interesting in this configuration!

 

I have tried to set up my zwave.me but without any luck so far after reading a lot on this topic (a bit confusing...).

If someone has got this working, it would be nice to get both Unraid docker setup and zwave config for the USB device!

 

Thanks!

/tompa

 

My Aeotech Z-stick is /dev/ttyACM0, so you should be able to add this as device pass through in the docker template. If it works or not depends on how the container is built.

It's working in my Domoticz container.

Link to comment

Thanks for your replay saarg, much appreciated!

 

My device;

root@T5:~# ls /dev/ttyACM*
/dev/ttyACM0

 

 

Adding this as "device" in docker template --device=/dev/ttyACM0, using Domoticz in this example and getting this error;

docker: Error response from daemon: error gathering device information while adding custom device "/dev/ttyUSB0": lstat /dev/ttyUSB0: no such file or directory.

 

Im lost at the moment ;)

/tompa

Link to comment

Thanks for your replay saarg, much appreciated!

 

My device;

root@T5:~# ls /dev/ttyACM*
/dev/ttyACM0

 

 

Adding this as "device" in docker template --device=/dev/ttyACM0, using Domoticz in this example and getting this error;

docker: Error response from daemon: error gathering device information while adding custom device "/dev/ttyUSB0": lstat /dev/ttyUSB0: no such file or directory.

 

Im lost at the moment ;)

/tompa

 

You have passed through /dev/ttyUSB0 also. Remove that one and it should work. You have to enable advanced view and remove it in the extra parameters box.

 

I didn't know there was already a domoticz container, so haven't tried it. The one I'm running is from us and will be released shortly (When I get some time to write up all the info and XML).

Link to comment

Not familiar with this, but when we passthrough devices for DVB you need to change permissions on the adapter to allow the docker to access.

 

For these devices all needed is to add the user running the software in the container to the dialout group. Which is done in our domoticz container  :)

Link to comment

Not familiar with this, but when we passthrough devices for DVB you need to change permissions on the adapter to allow the docker to access.

 

For these devices all needed is to add the user running the software in the container to the dialout group. Which is done in our domoticz container  :)

 

We have a domoticz container?  ???

Link to comment

Thanks for your replay saarg, much appreciated!

 

My device;

root@T5:~# ls /dev/ttyACM*
/dev/ttyACM0

 

 

Adding this as "device" in docker template --device=/dev/ttyACM0, using Domoticz in this example and getting this error;

docker: Error response from daemon: error gathering device information while adding custom device "/dev/ttyUSB0": lstat /dev/ttyUSB0: no such file or directory.

 

Im lost at the moment ;)

/tompa

 

You have passed through /dev/ttyUSB0 also. Remove that one and it should work. You have to enable advanced view and remove it in the extra parameters box.

 

I didn't know there was already a domoticz container, so haven't tried it. The one I'm running is from us and will be released shortly (When I get some time to write up all the info and XML).

 

Thanks, got it working with Domoticz now!  :D

 

I'm new to this and didn't understand the "advanced setting switch", I thought it was the "show advanced setting"  :P

 

Thanks again!

/tompa

Link to comment
  • 2 months later...

Just sharing what I've done:

 

  1. Inserted my Z Wave stick into my UNRAID server.
  2. Went to the main UNRAID log and found this:
    Feb 24 08:52:12 ChiRAID kernel: usb 5-1: new full-speed USB device number 4 using uhci_hcd
    Feb 24 08:52:12 ChiRAID kernel: cdc_acm 5-1:1.0: ttyACM0: USB ACM device
    Feb 24 08:52:12 ChiRAID kernel: usbcore: registered new interface driver cdc_acm
    Feb 24 08:52:12 ChiRAID kernel: cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters

     

  3.  Found that the system is referring to the stick as ttyACM0 per above.
  4.  Went into Home assistant docker settings, enabled advanced view, and made the following changes:
    Extra Parameters:	--device=/dev/ttyACM0
    Privileged:			ON
     
  5.  Followed instructions on setting up z-wave stick by adding the required code to the yaml file:
    zwave:
      usb_path: /dev/ttyACM0

     

 

Link to comment
9 hours ago, poldim said:

Just sharing what I've done:

 

  1. Inserted my Z Wave stick into my UNRAID server.
  2. Went to the main UNRAID log and found this:
    
    Feb 24 08:52:12 ChiRAID kernel: usb 5-1: new full-speed USB device number 4 using uhci_hcd
    Feb 24 08:52:12 ChiRAID kernel: cdc_acm 5-1:1.0: ttyACM0: USB ACM device
    Feb 24 08:52:12 ChiRAID kernel: usbcore: registered new interface driver cdc_acm
    Feb 24 08:52:12 ChiRAID kernel: cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters

     

  3.  Found that the system is referring to the stick as ttyACM0 per above.
  4.  Went into Home assistant docker settings, enabled advanced view, and made the following changes:
    
    Extra Parameters:	--device=/dev/ttyACM0
    Privileged:			ON
     
  5.  Followed instructions on setting up z-wave stick by adding the required code to the yaml file:
    
    zwave:
      usb_path: /dev/ttyACM0

     

 

 

Setting privileged to on makes your device tag excessive as privileged gives the container access to all devices of the host. If the container dev did it correctly the only thing you need is the device tag.

Link to comment
On 2/25/2017 at 2:03 AM, saarg said:

 

Setting privileged to on makes your device tag excessive as privileged gives the container access to all devices of the host. If the container dev did it correctly the only thing you need is the device tag.

True - I went back and removed the privileged tag and it's working without issues.  

 

Is there a clearly define way of how I get it to always load the zwave stick into the same path?  It seems that if I remove it and plug it back in, it jumps between ACM0 and ACM1, but not every time.

Link to comment
On 2/27/2017 at 1:21 PM, saarg said:

Probably is a way, but I don't know how. 

The easy way is to not unplug it ;-)

I've now had the device change it's address from /dev/ttyACM0 to /dev/ttyACM1 and /dev/ttyACM1 to /dev/ttyACM0 at separate times completely on it's own.  How do I stop this from happening?

Link to comment
11 minutes ago, poldim said:

I've now had the device change it's address from /dev/ttyACM0 to /dev/ttyACM1 and /dev/ttyACM1 to /dev/ttyACM0 at separate times completely on it's own.  How do I stop this from happening?

I have not had the same experience with my Z-wave stick. For some reason your device disconnects. Check your log for any USB errors. 

Link to comment
2 hours ago, saarg said:

I have not had the same experience with my Z-wave stick. For some reason your device disconnects. Check your log for any USB errors. 

 

Here's the log:

root@ChiRAID:~# cat /var/log/syslog | grep ttyACM

Feb 24 08:52:12 ChiRAID kernel: cdc_acm 5-1:1.0: ttyACM0: USB ACM device
Feb 24 13:32:54 ChiRAID kernel: cdc_acm 5-1:1.0: ttyACM1: USB ACM device
Feb 24 14:37:16 ChiRAID kernel: cdc_acm 5-1:1.0: ttyACM0: USB ACM device
Feb 24 15:04:46 ChiRAID kernel: cdc_acm 5-1:1.0: ttyACM0: USB ACM device
Feb 25 18:54:44 ChiRAID kernel: cdc_acm 5-1:1.0: ttyACM1: USB ACM device
Feb 25 19:05:48 ChiRAID kernel: cdc_acm 5-1:1.0: ttyACM1: USB ACM device
Feb 26 14:29:27 ChiRAID kernel: cdc_acm 2-1.4:1.0: ttyACM0: USB ACM device
Feb 26 14:35:32 ChiRAID kernel: cdc_acm 2-1.4:1.0: ttyACM0: USB ACM device
Feb 26 14:35:45 ChiRAID kernel: cdc_acm 2-1.4:1.0: ttyACM0: USB ACM device
Feb 26 14:35:59 ChiRAID kernel: cdc_acm 2-1.4:1.0: ttyACM0: USB ACM device
Feb 28 02:30:02 ChiRAID kernel: cdc_acm 2-1.4:1.0: ttyACM1: USB ACM device
Feb 28 09:55:06 ChiRAID root: home-assistant: Error response from daemon: linux runtime spec devices: error gathering device information while adding custom device "/dev/ttyACM0": lstat /dev/ttyACM0: no such file or directory Error: failed to start containers: home-assistantunifi: started succesfully!
Mar  1 02:30:01 ChiRAID kernel: cdc_acm 2-1.4:1.0: ttyACM0: USB ACM device
Mar  2 02:30:02 ChiRAID kernel: cdc_acm 2-1.4:1.0: ttyACM1: USB ACM device

I think I know what it is:

I had HA initializing a soft reset based on the suggestion on their zwave config page (all the way at the bottom) that ran nightly at 2:30.  

 

Any idea what's after cdc_acm in the log?  Is it the USB bus/device/etc?

 

 

I'd still like to find a solution to permanently bind the device to a static mapping.  I've got a separate thread HERE for it, but no responses.

 

Link to comment
1 hour ago, poldim said:

 

Here's the log:


root@ChiRAID:~# cat /var/log/syslog | grep ttyACM

Feb 24 08:52:12 ChiRAID kernel: cdc_acm 5-1:1.0: ttyACM0: USB ACM device
Feb 24 13:32:54 ChiRAID kernel: cdc_acm 5-1:1.0: ttyACM1: USB ACM device
Feb 24 14:37:16 ChiRAID kernel: cdc_acm 5-1:1.0: ttyACM0: USB ACM device
Feb 24 15:04:46 ChiRAID kernel: cdc_acm 5-1:1.0: ttyACM0: USB ACM device
Feb 25 18:54:44 ChiRAID kernel: cdc_acm 5-1:1.0: ttyACM1: USB ACM device
Feb 25 19:05:48 ChiRAID kernel: cdc_acm 5-1:1.0: ttyACM1: USB ACM device
Feb 26 14:29:27 ChiRAID kernel: cdc_acm 2-1.4:1.0: ttyACM0: USB ACM device
Feb 26 14:35:32 ChiRAID kernel: cdc_acm 2-1.4:1.0: ttyACM0: USB ACM device
Feb 26 14:35:45 ChiRAID kernel: cdc_acm 2-1.4:1.0: ttyACM0: USB ACM device
Feb 26 14:35:59 ChiRAID kernel: cdc_acm 2-1.4:1.0: ttyACM0: USB ACM device
Feb 28 02:30:02 ChiRAID kernel: cdc_acm 2-1.4:1.0: ttyACM1: USB ACM device
Feb 28 09:55:06 ChiRAID root: home-assistant: Error response from daemon: linux runtime spec devices: error gathering device information while adding custom device "/dev/ttyACM0": lstat /dev/ttyACM0: no such file or directory Error: failed to start containers: home-assistantunifi: started succesfully!
Mar  1 02:30:01 ChiRAID kernel: cdc_acm 2-1.4:1.0: ttyACM0: USB ACM device
Mar  2 02:30:02 ChiRAID kernel: cdc_acm 2-1.4:1.0: ttyACM1: USB ACM device

I think I know what it is:

I had HA initializing a soft reset based on the suggestion on their zwave config page (all the way at the bottom) that ran nightly at 2:30.  

 

Any idea what's after cdc_acm in the log?  Is it the USB bus/device/etc?

 

 

I'd still like to find a solution to permanently bind the device to a static mapping.  I've got a separate thread HERE for it, but no responses.

 

 

I have no idea what is after cdc_acm. Only having the lines with ttyACM from the log doesn't make any sense when troubleshooting. 

Link to comment
Feb 25 18:52:52 ChiRAID kernel: usb 5-1: USB disconnect, device number 7
Feb 25 18:54:44 ChiRAID kernel: usb 5-1: new full-speed USB device number 8 using uhci_hcd
Feb 25 18:54:44 ChiRAID kernel: cdc_acm 5-1:1.0: ttyACM1: USB ACM device
Feb 25 19:05:44 ChiRAID kernel: usb 5-1: USB disconnect, device number 8
Feb 25 19:05:48 ChiRAID kernel: usb 5-1: new full-speed USB device number 9 using uhci_hcd
Feb 25 19:05:48 ChiRAID kernel: cdc_acm 5-1:1.0: ttyACM1: USB ACM device
Feb 25 19:07:15 ChiRAID emhttp: cmd: /usr/local/emhttp/plugins/dynamix/scripts/tail_log syslog
Feb 25 21:27:00 ChiRAID kernel: br0: port 3(vnet1) entered disabled state
Feb 25 21:27:00 ChiRAID kernel: device vnet1 left promiscuous mode
Feb 25 21:27:00 ChiRAID kernel: br0: port 3(vnet1) entered disabled state
Feb 26 00:00:01 ChiRAID kernel: mdcmd (40): check 
Feb 26 00:00:01 ChiRAID kernel: md: recovery thread: check P ...
Feb 26 00:00:01 ChiRAID kernel: md: using 1536k window, over a total of 4883770532 blocks.
Feb 26 01:00:01 ChiRAID root: mover started
Feb 26 01:00:01 ChiRAID root: mover finished
Feb 26 09:08:55 ChiRAID kernel: md: sync done. time=32934sec
Feb 26 09:08:55 ChiRAID kernel: md: recovery thread: completion status: 0
Feb 26 14:28:36 ChiRAID kernel: usb 5-1: USB disconnect, device number 9
Feb 26 14:28:44 ChiRAID kernel: usb 2-1: new high-speed USB device number 10 using ehci-pci
Feb 26 14:28:44 ChiRAID kernel: hub 2-1:1.0: USB hub found
Feb 26 14:28:44 ChiRAID kernel: hub 2-1:1.0: 4 ports detected
Feb 26 14:29:27 ChiRAID kernel: usb 2-1.4: new full-speed USB device number 11 using ehci-pci
Feb 26 14:29:27 ChiRAID kernel: cdc_acm 2-1.4:1.0: ttyACM0: USB ACM device
Feb 26 14:34:33 ChiRAID emhttp: cmd: /usr/local/emhttp/plugins/dynamix/scripts/tail_log syslog
Feb 26 14:34:59 ChiRAID emhttp: cmd: /usr/local/emhttp/plugins/dynamix/scripts/tail_log syslog
Feb 26 14:35:20 ChiRAID emhttp: cmd: /usr/local/emhttp/plugins/dynamix/scripts/tail_log syslog
Feb 26 14:35:23 ChiRAID kernel: usb 2-1: USB disconnect, device number 10
Feb 26 14:35:23 ChiRAID kernel: usb 2-1.4: USB disconnect, device number 11
Feb 26 14:35:32 ChiRAID kernel: usb 2-1: new high-speed USB device number 12 using ehci-pci
Feb 26 14:35:32 ChiRAID kernel: hub 2-1:1.0: USB hub found
Feb 26 14:35:32 ChiRAID kernel: hub 2-1:1.0: 4 ports detected
Feb 26 14:35:32 ChiRAID kernel: usb 2-1.4: new full-speed USB device number 13 using ehci-pci
Feb 26 14:35:32 ChiRAID kernel: cdc_acm 2-1.4:1.0: ttyACM0: USB ACM device
Feb 26 14:35:41 ChiRAID kernel: usb 2-1: USB disconnect, device number 12
Feb 26 14:35:41 ChiRAID kernel: usb 2-1.4: USB disconnect, device number 13
Feb 26 14:35:44 ChiRAID kernel: usb 2-1: new high-speed USB device number 14 using ehci-pci
Feb 26 14:35:45 ChiRAID kernel: hub 2-1:1.0: USB hub found
Feb 26 14:35:45 ChiRAID kernel: hub 2-1:1.0: 4 ports detected
Feb 26 14:35:45 ChiRAID kernel: usb 2-1.4: new full-speed USB device number 15 using ehci-pci
Feb 26 14:35:45 ChiRAID kernel: cdc_acm 2-1.4:1.0: ttyACM0: USB ACM device
Feb 26 14:35:54 ChiRAID kernel: usb 2-1: USB disconnect, device number 14
Feb 26 14:35:54 ChiRAID kernel: usb 2-1.4: USB disconnect, device number 15
Feb 26 14:35:58 ChiRAID kernel: usb 2-1: new high-speed USB device number 16 using ehci-pci
Feb 26 14:35:59 ChiRAID kernel: hub 2-1:1.0: USB hub found
Feb 26 14:35:59 ChiRAID kernel: hub 2-1:1.0: 4 ports detected
Feb 26 14:35:59 ChiRAID kernel: usb 2-1.4: new full-speed USB device number 17 using ehci-pci
Feb 26 14:35:59 ChiRAID kernel: cdc_acm 2-1.4:1.0: ttyACM0: USB ACM device

 

Link to comment

I've been fighting this same annoyance (ttyACM0 => ttyACM1 =>ttyACM0) since I set up my z-wave network last month.

 

A quick lsusb -v would confirms  Aeon Labs Aeotec Z-Wave Z-Stick, Gen5 maps to idVendor=0658 idProduct=0200

 

Bus 001 Device 008: ID 0658:0200 Sigma Designs, Inc.
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            2 Communications
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0         8
  idVendor           0x0658 Sigma Designs, Inc.
  idProduct          0x0200
  bcdDevice            0.00
  iManufacturer           0
  iProduct                0
  iSerial                 0
  bNumConfigurations      1

 

Given that, I'm planning on editing my go script to create the udev rule:

echo 'SUBSYSTEM=="tty", ATTRS{idVendor}=="0658", ATTRS{idProduct}=="0200", SYMLINK+="zwave"' > /etc/udev/rules.d/99-usb-serial.rules

I manually created the rule, unplugged and replugged the zwave stick, and it looks like the rule works:

me@tower:/# ls -al /dev/zwave
lrwxrwxrwx 1 root root 7 Mar 11 19:12 /dev/zwave -> ttyACM0

I passed the udev alias to docker:

--device=/dev/zwave

and mapped to it in my configuration.yaml


 

zwave:
 usb_path: /dev/zwave

 

Aside from the mess of sensors I need to go map, everything appears to be working.  I just don't know if this is durable beyond a reboot.   @Saarg's comment below makes me wonder.    Where can i find the CHBMB build script?

 

On 5/25/2016 at 4:56 AM, saarg said:

I don't know how udev works, but I suspect the udev rule have to be made before the go script executes for this to work?

If so, you will have to unpack bzroot, add the udev rule and then pack it again. You could look at CHBMB build script for the media build for how to do it.

 

Link to comment
  • 4 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.