I can create two linked virtual serial ports on a Linux system with
socat, and pretend one end is a serial device, and the other one is some code that uses the device. The
socat command would look like:
socat -d -d pty,raw,echo=1 pty,raw,echo=0
And it creates two ports on the system, e.g.
Now, I want to go one step further, and have two docker containers representing the system: one container pretending to be the serial device, and the other container being the code using that device. The goal being that when in production, I can remove the virtual device container and just use the real sensor.
The problem is that I can't seem to find a way to share the
devpts between two containers, and somehow it feels like it is not something good to do.
Would there be a way to achieve the exact same behavior (virtual serial ports) by using named pipes instead of pty? Then I could share the file (say "/home/user/folder/my_pipe") between the containers (actually I would mount "/home/user/folder" on both, and both would then access
Or is there another, better way to do all that with docker?