I want to use a serial USB device in a Docker container. Unfortunately, the USB device sometimes reconnects. The device name then changes from ttyUSB1 to ttyUSB2.
To compensate for this, I’m using a symbolic link: ttyUSB_DEVICE1
When the container starts, ttyUSB_DEVICE1 works correctly.
crw-rw---- 1 root dialout 188, 1 Nov 19 16:08 /dev/ttyUSB1
lrwxrwxrwx 1 root root 7 Nov 19 16:08 /dev/ttyUSB_DEVICE1 → ttyUSB1
After a reconnect, the device is unreachable within the container.
crw-rw---- 1 root dialout 188, 2 Nov 13 08:44 /dev/ttyUSB2
lrwxrwxrwx 1 root root 7 Nov 13 08:44 /dev/ttyUSB_DEVICE1 → ttyUSB2
I expected Docker to use the symbolic link that points to ttyUSB2 after reconnecting. Unfortunately, it doesn’t.
I have to reset the USB device so it’s called ttyUSB1 again.
Does anyone know a solution to this problem other than restarting the Docker container after reconnecting?