Passing usb devices to docker (zwave usb)

Hi,

I recently moved to docker, and I noticed in the oh docker documentation for usb you mention this should be run on container start

docker exec \
    -d \
    openhab \
    /bin/chmod o+rw /dev/ttyACM0

I didnt do that, I just have this in docker compose

    group_add:
      - "20"

I also did this on the host

sudo usermod -aG dialout openhab

but maybe this is not even required, I think it would work just with the group in compose.yml.

I’m running aeotec zwave usb stick with no issues.

Maybe you want to update the section on docker / usb sticks as this solution seems less “dirty” then run the command on every restart

IMO the docs don’t get to the docker-compose.yml information until the end. This what I use for an Aeotec stick You could just use /dev/ttyACM0, but as noted it can change and the newer sticks use USBX

services:
  openhab:
    image: "openhab/openhab:milestone"
    restart: always
    network_mode: host
    volumes:
      - "/etc/localtime:/etc/localtime:ro"
      - "/etc/timezone:/etc/timezone:ro"
      - "/etc/cont-init.d:/etc/cont-init.d"
      - "./openhab_addons:/openhab/addons"
      - "./openhab_conf:/openhab/conf"
      - "./openhab_userdata:/openhab/userdata"
    devices:
       # Do not use /dev/ttyUSBX serial devices, as those mappings can change over time. Instead, use the /dev/serial/by-id/X serial device for your Z-Wave stick.
      - '/dev/serial/by-id/usb-0658_0200-if00:/dev/zwaveoh'
    environment:
      CRYPTO_POLICY: "unlimited"
      EXTRA_JAVA_OPTS: "-Duser.timezone=America/New_York"
      OPENHAB_HTTP_PORT: "8080"
      OPENHAB_HTTPS_PORT: "8443"
      USER_ID: "1000"
      GROUP_ID: "1000"

Four commands are most used by me

docker compose down
docker compose up -d // suppresses logging 
docker compose pull  && docker compose up -d  //upgrade
docker exec -it openhab-openhab-1 /openhab/runtime/bin/client // karaf for openhab-openhab-1 container

It has been a long time since I set up my Docker deployment for openHAB and I use Ansible to do it, not docker run nor docker compose (though Ansible does call those itself). I also no longer have a USB dongle that needs to be directly passed into the container anymore. But I am 100% certain I have never had to run that command in the container nor have I ever had to use the group_add command.

Looking at the entrypoint, as I suspected, it adds the openhab user to all the dialout type groups for you.

As I understand it, neither the command from the docs nor the group_add option to docker run or docker compose are required.

great, then those warnings / instructions that openhab docker will not be able to access the usb without that dirty command on runtime should be removed from docs I guess

i even tried to verify it by googling, and indeed found some users on this forum complain their stick is not seen…but this was obviously so long ago before the entrypoint was improved to solve it