webdevops / gq-gmc-exporter

Prometheus exporter for GQ GMC (Geiger–Muller counter) devices
MIT License
4 stars 0 forks source link

Mounting USB device to Docker container #2

Closed realies closed 3 years ago

realies commented 3 years ago

What's the expected way to mount the USB device to a gq-gmc-exporter Docker container? Doing so with either --device=/dev/ttyUSB0 or --privileged /dev/bus/usb:/dev/bus/usb as extra parameters fails to start the container with

{"file":"serial.go:45","func":"Connect","level":"panic","msg":"cannot open /dev/ttyUSB0: open /dev/ttyUSB0: permission denied"}

The post parameters are:


--serial.port=/dev/ttyUSB0 --serial.baudrate=57600 --serial.databits=8 --serial.stopbits=1 --bind=8080
mblaschke commented 3 years ago

i'm running it with:

docker-compose.yaml

version: '3.4'
services:
  gqgmc:
    image: webdevops/gq-gmc-exporter:21.8.2
    volumes:
      - /dev:/dev
    environment:
    - SERIAL_PORT=/dev/serial/by-id/usb-1a86_USB_Serial-if00-port0
    - SERIAL_BAUDRATE=57600
    - SERIAL_DATABITS=8
    - SERIAL_STOPBITS=1
    user: 0:0
    privileged: true
    restart: always

if your device is only accessiable by user root you have to run also the container as root 0:0 or change the permissions for the device.