可以添加具有序列号的设备:
class MyClass(object):
def __init__(self, x):
self.x = x
a = MyClass(3)
print(a.__class__.__name__)
if a.__class__.__name__ == "MyClass":
...
不能通过串行路径添加设备:
docker run -it --rm --device /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A101A9A7-if00-port0 -v /dev:/dev ubuntu /bin/bash
它报告错误:
“-device”标志的无效参数“ /dev/serial/by-path/pci-0000:00:14.0-usb-0:8:1.0-port0”:路径格式错误:/ dev / serial /by-path/pci-0000:00:14.0-usb-0:8:1.0-port0
请参阅“ docker run --help”。
如果下一个对docker run -it --rm --device /dev/serial/by-path/pci-0000:00:14.0-usb-0:8:1.0-port0 -v /dev:/dev ubuntu /bin/bash
进行转义,则错误相同:
:
据我所知,对于docker run -it --rm --device /dev/serial/by-path/pci-0000\:00\:14.0-usb-0\:8\:1.0-port0 -v /dev:/dev ubuntu /bin/bash
,我们现在可以使用bind mount
之类的东西来处理它,请参见this。
所以我的问题是:对于--mount type=bind,source=/colon:path/test,destination=/data
,我该怎么办?
答案 0 :(得分:0)
从this discussion开始为自己解答:
CLI似乎不支持对冒号进行转义,当前唯一的方法是使符号链接如下所示:
ln -s /dev/serial/by-path/pci-0000:00:14.0-usb-0:8:1.0-port0 /dev/serial/by-path/mydevice01
docker run -it --rm --device /dev/serial/by-path/mydevice01 -v /dev:/dev ubuntu /bin/bash
这是我目前的解决方法。