Trying but failing to use serial by-id in Docker

In my mind this should work, using a symlink to the actual serial by-id in the host:
devices:
- /media/pi/Docker/Docker-Compose/SignalK/garmin-usb-0:/dev/serial/by-id/usb-067b_2303-if00-port0 #Garmin
devices:
- /media/pi/Docker/Docker-Compose/SignalK/garmin-usb-0:/dev/serial/by-id/usb-067b_2303-if00-port0 #Garmin
But it doesn't. This, on the other hand, works on the same symlink, but it keeps getting mixed up with the Sailorhat, which is supposed to stay on USB1:
devices:
- /media/pi/Docker/Docker-Compose/SignalK/garmin-usb-0:/dev/ttyUSB0 #Garmin
devices:
- /media/pi/Docker/Docker-Compose/SignalK/garmin-usb-0:/dev/ttyUSB0 #Garmin
I don't understand why, but sometimes after a reboot USB0 and USB1 has traded places inside the Docker image. It could be avoided by using serial by-id, but isn't that supported?
6 Replies
Teppo Kurki
Teppo Kurki4w ago
are quite sure about your configuration snippets? devices entries are of the form HOST_PATH:CONTAINER_PATH[:CGROUP_PERMISSIONS] so yours look reversed i don't think mapping a symlink from the host to the container works by default symlink is essentially a special file that contains the path to the target, so the target must also be there inside the container, with the same exact path /dev/serial:/dev/serial has been working for me
Mastiff
Mastiff4w ago
This is Docker Compose, I forgot to say that. But I will try /dev/serial, thanks!
Teppo Kurki
Teppo Kurki4w ago
I was referring to docker compose syntax
Mastiff
Mastiff4w ago
Oh, sorry. But no, they are not reversed. Those are the symlinks I created when the serial by path with many colons stopped working. So I have symlinks (and I know they work) in the Docker Compose directory for SignalK. /dev/sailorhat and /dev/garmin did not work for me, but /dev/ttysailorhat and /dev/ttygarmin did. And it seems like the problem that on some startups of the container they are mixed when using usb0 and usb1 is gone. 😁
Teppo Kurki
Teppo Kurki4w ago
sorry, I don't understand. what creates those paths? why would ones with tty work and the ones without them not?
Mastiff
Mastiff4w ago
I have no idea why one work and another one doesn't. The paths are created in Docker Compose file, as I said above, from symbolic links in the Docker Compose directory that points to the devices in serial by-id. I'm sure it would work just as well to use the serial by-id addresses in the Docker Compose file, but the symlinks makes it easy to see what is what.
Want results from more Discord servers?
Add your server