1

I have an Arduino at /dev/ttyUSB0 that is outputting simple strings. I want to be able to view this serial output inside a docker container.

On my host machine (Ubuntu 18.04) I am able to see the output with

user@host:~$ sudo screen /dev/ttyUSB0 9600

Hello! 1
Hello! 2
Hello! 3
...

but when I run the same command in an ubuntu:latest docker container I get [screen is terminating].

I have tried running ubuntu:latest with both

user@host:~$ docker run -it --device=/dev/ttyUSB0 ubuntu:latest /bin/bash

and

user@host:~$ docker run -it -v /dev/ttyUSB0:/dev/ttyUSB0 ubuntu:latest /bin/bash

Please note, I do not want to run the container with the --privileged flag.

Then I install required deps for screen:

root@container:/# apt-get update; apt-get -y install libterm-readline-perl-perl dialog apt-utils screen

Why can I run screen on my host but not in my ubuntu docker container? What else do I need to do to be able to see the output from /dev/ttyUSB0 in the container?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Wimateeka
  • 2,474
  • 2
  • 16
  • 32
  • See https://stackoverflow.com/questions/24225647/docker-a-way-to-give-access-to-a-host-usb-or-serial-device – Pierre B. Mar 22 '19 at 15:48
  • @PierreB. I can see the device just fine, the problem is running `screen` and not the device connection. – Wimateeka Mar 22 '19 at 15:52
  • My bad, didn't see you were already using --device already. I noted you did not want to run in privileged mode, but have you tested with --privileged just to see if it was working or not? – Pierre B. Mar 22 '19 at 15:55
  • I can see output in the container with `--privileged`. But I want to connect just this singular device and not all the other important things in `/dev` – Wimateeka Mar 22 '19 at 15:58

0 Answers0