How to EXPOSE COM PORT

Hi,

I am new to docker and I tried to run a python script in docker and got the following error

Traceback (most recent call last):
File “./script.py”, line 18, in
ser=serial.Serial(’/dev/ttyS1’,baudrate=9600,timeout=0)
File “/usr/local/lib/python3.6/site-packages/serial/serialutil.py”, line 240, in init
self.open()
File “/usr/local/lib/python3.6/site-packages/serial/serialposix.py”, line 268, in open
raise SerialException(msg.errno, “could not open port {}: {}”.format(self._port, msg))
serial.serialutil.SerialException: [Errno 2] could not open port /dev/ttyS1: [Errno 2] No such file or directory: ‘/dev/ttyS1’

My Dockerfile is as follows:

FROM python:3

ADD script.py /

RUN pip install pystrich

RUN pip install pyserial

CMD [ “python”, “./script.py” ]

Guessing that the error is caused because the port is not exposed ; how do I expose port ttyS1 ?
Thanks.

Hi,

I am wondering if you got anywhere with this issue. I have a python 3 app that uses PySerial, and I want to dockerize it. I access UART and JTAG ports on embedded test systems over USB.

Any insights would be greatly appreciated.

Thanks!
– Edward