-
Notifications
You must be signed in to change notification settings - Fork 386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
can not pass through /dev/tty* to docker image #15
Comments
Thanks for reporting this. If you could me with the following information, it'll help me investigate. Can you tell me exactly what platform you are running on? |
Thanks for looking into it. I was talk with DCJ via email but it is probably best to do it here... The command that I use is:- I have a usb-serial interface on ttyACM0 (ciseco/wireless things adapter). I can see that the port is passed through to docker: The docker containers are started as root. (The errors shown in my first post are logs from inside the container, not the host) Some time ago I built a docker for Node Red, this one works well (currently v0.14.6):
Wondering if it is the combination of USER not root and support for serial in Alpine linux base docker? |
Thanks for the above information, I'll dig into this over the next week and get back to you. |
Can you do a |
root@Tower: |
Re-reading the first comment, we can fix the "user not running as root" issue using the "--user" command-line flag which leads us to the second issue... Where are those binding files? The mystery continues... Looking at the Travis build logs, I can see that the bindings files are installed to here: Can you check this file is available inside the container? |
seems to be there! How do I use the --user flag? |
It looks like the "user not running as root" also has to be in the "dialout" group to give it access to the tty. |
agree, I think node-red user needs to be in the dialout group. I couldnt add it in the running docker, so I tried a rebuild with nodered starting as root. I then had the problem with serialport.node not found. Maybe there is a specific version for alpine linux (that the docker is built from)? |
Notes from DCJ or maybe do the udev rules thing... - (not sure how to do that inside docker) "You could use UDEV. It's a system that triggers every time plug or unplug a device (amongst other stuff). With it, you script various things to happen, including setting permissions. Save, exit and replug and you should be up and running. Setting the permission to 666 allows anybody to write to the device. Copied for reference ...... |
can you add RUN usermod -a -G dialout node-red |
Dave, that didnt work:
Step 1 : FROM node:4 docker built ok but got the same: docker exec nodered ls -l /dev/ttyACM0crw-rw---- 1 root 16 166, 0 Oct 17 22:01 /dev/ttyACM0 ls -l /dev/ttyACM0crw-rw---- 1 root dialout 166, 0 Oct 16 23:06 /dev/ttyACM0 |
Can you also check if node-red user did get added to the group ? |
this was my dockerfile: Home directory for Node-RED application source code.RUN mkdir -p /usr/src/node-red User data directory, contains flows, config and nodes.RUN mkdir /data WORKDIR /usr/src/node-red Add node-red user so we aren't running as root.RUN useradd --home-dir /usr/src/node-red --no-create-home node-red RUN usermod -a -G dialout node-red USER node-red Interestingly: |
dialout : x : 20 : node-red spaces added to stop auto emoji thingy |
It works!... Using the following as parameters... Thanks Team - I can now update the template for the Node Red users on unRaid. --device=/dev/ttyACM0 --user=root |
🎉🎉🎉 |
Ok, that "user thing" works, but wasn't this a workaround? |
Just as a heads up, this works until your device resets and becomes ttyACM1 while the container is running. If that happens, you won't be able to talk to it. There is a workaround that isn't --privileged though, details here: http://marc.merlins.org/perso/linux/post_2018-12-20_Accessing-USB-Devices-In-Docker-_ttyUSB0_-dev-bus-usb-_-for-fastboot_-adb_-without-using-privileged.html |
Is there any way to get this line:
into the official dockerfile? I tried it on different systems and with different devices. It is the only command i have to rerun everytime I pull nodered. After this command the serial connection works without a problem. |
I solve this permission issue by adding
|
That works great for docker run, and works for docker-compose if your compose file is in v2 format. It was removed for v3, but it's back if you install docker-compose 1.27.0+ and are running Docker Engine 19.03.0+.
|
using --device=/dev/ttyACM0 on docker commandline....
the "serial in" node cannot connect due to Permisson error - from the log in th edocker:
[error] serial port /dev/ttyACM0 error: Error: Error: Permission denied, cannot open /dev/ttyACM0
It may be due to user node-red not having access to /dev/
I have tried editing the Dockerfile to remove USER node-red (to run Node-Red as root but serial then produces these errors (on LATEST docker - not RPI):
[warn] [serialport] Error: Could not locate the bindings file. Tried:
→ /usr/src/node-red/node_modules/node-red/node_modules/node-red-node-serialport/node_modules/serialport/build/serialport.node
→ /usr/src/node-red/node_modules/node-red/node_modules/node-red-node-serialport/node_modules/serialport/build/Debug/serialport.node
→ /usr/src/node-red/node_modules/node-red/node_modules/node-red-node-serialport/node_modules/serialport/build/Release/serialport.node
→ /usr/src/node-red/node_modules/node-red/node_modules/node-red-node-serialport/node_modules/serialport/out/Debug/serialport.node
→ /usr/src/node-red/node_modules/node-red/node_modules/node-red-node-serialport/node_modules/serialport/Debug/serialport.node
→ /usr/src/node-red/node_modules/node-red/node_modules/node-red-node-serialport/node_modules/serialport/out/Release/serialport.node
→ /usr/src/node-red/node_modules/node-red/node_modules/node-red-node-serialport/node_modules/serialport/Release/serialport.node
→ /usr/src/node-red/node_modules/node-red/node_modules/node-red-node-serialport/node_modules/serialport/build/default/serialport.node
→ /usr/src/node-red/node_modules/node-red/node_modules/node-red-node-serialport/node_modules/serialport/compiled/4.6.0/linux/x64/serialport.node
Any idea how I can get a serial pass through to work on the official Docker image (it works on my unofficial version)
The text was updated successfully, but these errors were encountered: