docker-compose devices map all devices from local to container

Viewed 117

I have this docker-compose service that i am trying to make work.

  app:
    build: ./
    volumes:
      - .:/app:delegated
    devices:
      - ${VARIABLE:-/dev/ttyUSB*}:${VARIABLE:-/dev/ttyUSB*}

Response when running docker-compose up app

Error response from daemon: error gathering device information while adding custom device "/dev/ttyUSB*": no such file or directory

The idea here is to get all devices that match /dev/ttyUSB* from local and create them inside the container. This way i can have 0-N devices in the container, handling scenarios when no devices are connected. Also I do not have to know each device's tty<id>

I have read some old answers like this one : mapping all available devices in docker-compose but these either use

--privileged or do not answer the question of how to get (all | no devices) copied and accessible.

I am aware that:

app:
    build: ./
    volumes:
      - .:/app:delegated
    devices:
      - ${VARIABLE:-/dev/ttyUSB0}:${VARIABLE:-/dev/ttyUSB0}

works but not when the device is assigned a different number, hence the need to map them all.

0 Answers
Related