I have a script that communicates over serial port (/dev/ttyUSB0
). I want to run it from within a Docker image. However I don't seem to have permissions to do it from within the image. I follow these steps:
On my host, if I run ln -l /dev/ttyUSB0
I get:
crw-rw---- 1 root dialout 188, 0 jul 2 14:34 /dev/ttyUSB0
Good, it means that in order to read/write to it, I need to be either root
, or part of the dialout
group.
I become member of this group in my host:
$ sudo usermod -aG dialout $(whoami)
Then I log out and log in again to make this effective.
After that, I verify that I can communicate perfectly with /dev/ttyUSB0
from my host. However if I run the docker image:
docker run --user=1000:1000 --rm=true --tty=true --privileged=true --device=/dev/ttyUSB0 --volume=<my_dir>:<my_dir> --workdir=<my_dir> <my_docker_image> <my_script>
Then it complains:
can't open device "/dev/ttyUSB0": Permission denied
However if I use: --user=1000:20
, then it works fine. The group 20
is the dialout
group.
Now my question:
Why does Docker not understand that my user (1000) and group (1000) is part of the dialout
group?
This was working when I used the old docker (apt-get install docker-io, docker-engine
), but after updating to the new Docker CE
this stopped working.
Setup:
- Ubuntu 16.04.2 LTS Kernel 4.4.0-83-generic.
- Docker version: Docker version 17.06.0-ce, build 02c1d87.
Thanks!