Connect to a local USB port on docker

2,055 views
Skip to first unread message

Bart Van der Auweraert

unread,
Oct 31, 2016, 4:30:04 PM10/31/16
to Node-RED

Hi, I'm trying to connect a arduino via usb to my docker instance running on my local machine


The command I use is:


docker run -it -p 1880:1880 -v /dev/bus/usb:/dev/bus/usb mynodered


But when i try to connect to the com3 port (where arduino is connected to), i got the error message "Cannot Open COM3"


The same nodered flows runs fine on my local machine without docker


any idea?

Ben Hardill

unread,
Oct 31, 2016, 4:35:54 PM10/31/16
to Node-RED
Since docker presents a Linux environment to the application the serial port is not going to be named COM3.

It's going to have a name like /dev/ttyUSBX where X is most likely going to be 0 as the first USB serial port on the docker container.

I've never tried to map a port to a docker container, but you look to be mapping the whole usb subsystem not just a single port. Are you sure that's right?

Julian Knight

unread,
Nov 2, 2016, 4:22:09 PM11/2/16
to Node-RED
com3 is only a Windows designation so when you are mapping, I'd assume it would be com3 on the outside and /dev/... on the inside.

Tony Neal

unread,
Nov 8, 2016, 2:27:52 PM11/8/16
to Node-RED
I had all sorts of problems with the official docker as I was passing through ttyACM0 (linux) which was a usb serial device.

We found out that you need to add the --user=root command as well.

My line is (with extra stuff that you dont need)

docker run -d --name="NodeRed-OfficialDocker" --net="host" -e TZ="Europe/London" -e HOST_OS="unRAID" -e "TCP_PORT_1880"="1880" -e "TCP_PORT_55000-55010"="55000-55010" -v "/mnt/user/appdata/nodered-official/":"/data":rw --device=/dev/ttyACM0:/dev/ttyACM0 --user=root nodered/node-red-docker

Ben Hardill

unread,
Nov 9, 2016, 11:03:03 AM11/9/16
to Node-RED
That will be because the default user in the container is not part of the dialout group which it would need to have access to the serial port. Forcing it to run as root by passes that, but it probably not the best idea

Julian Knight

unread,
Nov 10, 2016, 4:46:25 AM11/10/16
to Node-RED
This issue of devices belonging to root comes up a lot. Most of the advice seems to be to hack the process to run as root. Personally, I find that advice troubling, especially if you plan to release connectivity across the Internet.

I think that the preferred choice should be to change the permissions on the device link so that the correct user has sufficient access. This is easily done with a chmod command & it can be made part of your setup script.

Nicholas O'Leary

unread,
Nov 10, 2016, 4:49:04 AM11/10/16
to Node-RED Mailing List
Julian,

you do not need to chmod - as Ben said, your user needs to be in the dialout group at which point it gets the access it needs.

Nick

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/8b08fae5-17d2-4e50-bab2-db1c16781703%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages