我有这个 docker-compose 服务,我正在尝试使其工作。
app:
build: ./
volumes:
- .:/app:delegated
devices:
- ${DEVICE:-/dev/null}:-/dev/ttyUSB*
Run Code Online (Sandbox Code Playgroud)
运行时响应docker-compose up app
Error response from daemon: error gathering device information while adding custom device "/dev/ttyUSB*": no such file or directory
Run Code Online (Sandbox Code Playgroud)
这里的想法是从本地获取所有匹配的设备/dev/ttyUSB*并在容器内创建它们。这样我就可以在容器中拥有 0-N 个设备,处理没有设备连接时的场景。我也不必知道每个设备的tty<id>
我读过一些旧答案,例如: 在 docker-compose 中映射所有可用设备 ,但这些要么使用
--privileged或者不回答如何复制和访问(所有|无设备)的问题。
我知道:
Error response from daemon: error gathering device information while adding custom device "/dev/ttyUSB*": no such file or directory
Run Code Online (Sandbox Code Playgroud)
有效,但当设备被分配不同的编号时无效,因此需要将它们全部映射。