我有一个用于gps的python脚本。在我的python脚本中,它检测连接了哪个串口。例如,它可以是ttyACM0或ttyACM1。脚本检测串口,然后启动gps功能。
我想将这个gps脚本与docker-compose一起作为终端用户的简单设置,然而,在本地机器中,usb设备被检测为/dev/ttyACM0 0,而gps容器则表示它被检测为/dev/ttyACM0 1。
当我在本地机器中执行cat /dev/ttyACM0时,会显示gps信息,但当我在停靠容器中输入命令行cat /dev/ttyACM1时,显示的是cat: /dev/ttyACM1: No such device or address。
gps对接文件
FROM python:3.8
WORKDIR /gps
RUN apt update -y && apt install libusb-1.0-0-dev -y
RUN pip3 install -U pip && pip3 install pynmea2==1.18.0 pyusb==1.2.1 pyserial==3.5gps对接组合
version: '3.7'
services:
gps:
build:
context: docker
dockerfile: Dockerfile_gps
privileged: true
volumes:
- ./gps:/gps
restart: always
working_dir: /gps
command: python3 gps_operations.py发布于 2022-11-16 14:39:52
解决了这个问题。添加这些行解决了问题。
environment:
- UDEV=1
devices:
- '/dev:/dev'https://stackoverflow.com/questions/74462107
复制相似问题