Docker access serial device from host and container?

I have a serial device /dev/ttyACM0, that I would like to access it from the host and inside the docker container and this serial device is connected in a loop back mode (meaning i send a data, it will receive the same data)

I pass the serial device into the container as follow:

docker run -v /dev/ttyACM0:/dev/ttyACM0 node

I have an application inside the docker container that sends a message every 1 second,

In my host, I have the same application that receives the message send from the application inside container, and resend the message.

I found that, there is a some problem when I did this, sometimes I will get data corruption,

  • i) is it possible to share the serial device and open it at same time from host and container?
  • ii) what are the disadvantage of doing this?
  • iii) how can i solve the data corruption problems?