Can't connect to USB device when running in Docker

Hello,
I’m running lw4 as a docker image on a RaspberryPi 3.
The RRI is connected via USB to the Ortur LaserMaser2 on ttyACM0.
I’m using the folowing docker-compose file :

version: '2.4'

services:
  lawerweb4:
    image: laserweb4:latest
    restart: unless-stopped
    ports:
      - 82:8000
    devices:
      - /dev/ttyACM0:/dev/ttyACM0

The service runs fine and I can get the web interface.
But when I attempt to connect to the machine, the port is not detected and I cannot select any port for my USB connexion.

image

what is wrong, is there something else that should be defined in the docker-compose.

Nota : when running “outside” docker (as a normal rpi install) it is working fine.

Thanks.

Sounds like you’ve already narrowed down the issue with the device connection. Have you searched google for docker setup accessing USB serial devices? My guess is access control as maybe the Docker user does not have the same dialout group privileges as the pi user.

1 Like

hi, thanks for you hints
I did as you said but it seems my access are right :

  • ps -aux | grep node shows my process is running as root.
  • I changed devices: - /dev/ttyACM0:/dev/ttyACM0 to volumes - /dev:/dev and ttyACM0 appears when I ls from inside the docker with root owner.
  • I created some udev rules to allow for my device. that didn’t change anything…

any other idea ?

thanks.

with LaserWeb running, open a console on that Docker image and show the long listing( ls -l ) of the /dev/ttyACM0 device and then run a process listing to show what owner is running the laserweb daemon( ps -fe | grep -i laserweb )

here are the commands you asked from within the laserweb docker container.

1 Like

You got me, it sure looks correct so I would expect the laserweb server to find the device.

And when laserweb is started there’s nothing in the logs about access devices? Just considering something might not have installed in the docker container so it’s operating differently from when installed native on RaspbianOS.

Hi,

Nothing special in the logs, even after enabling DEBUG LOGGER; just this :

> laserweb@4.0.998 start-server /usr/src/app
node node_modules/lw.comm-server/server.js
***************************************************************
        ---- LaserWeb Comm Server 4.0.136 ----        
***************************************************************
  Use  http://172.17.0.2:8000 to connect this server.
* Updates: 
  Remember to check the commit log on
  https://github.com/LaserWeb/lw.comm-server/commits/master
  regularly, to know about updates and fixes, and then when ready
  update accordingly by running git pull
* Support: 
  If you need help / support, come over to 
  https://plus.google.com/communities/115879488566665599508
***************************************************************
 
App connected! (id=0)
INFO: Requesting Server Config 
App disconnected! (id=0)
App connected! (id=0)
INFO: Requesting Server Config 

Any way to turn on more logs ?
It’s running on RaspberryPI 3 with Raspbian Linux 5.10.17-v7+ armv7l

Cheers

wow, so no logging when you open the connection dialog or anything. Weird.

Did you try starting up LaserWeb without anything connected to USB and then connect your laser after LaserWeb was running? Just shotgunning things at this point. Otherwise I would be checking config files to compare between the working native install and the Docker install.

I see that G+ was still set as the support forum in the code… And see that MakerForums is their preferred support forum. I made a pull request to fix the G+ link to MakerForums.

On another note, I would also run through to make darn sure your Docker container was running only the preferred nodejs and serial port versions. ie matching what was installed natively. Sometimes, two packages of differing versions can be installed and you think it’s running on one version but it’s defaulting to another version. I’ve done this myself with python stuff many times.

Did you set the server ip (and port 8000) in the frontend?
The default points to localhost, not the server.

You can change the log and verbose level in config.js or via the .env file, where 0 is the lowest level and 3 is the highest. To get the most screen output add “VERBOSE_LEVEL=3” to the .env file, or “LOG_LEVEL=3”, if you want the output in the logfile.

Hi,
I did play arround with log with no success. Log doesn’t have any new lines…
here is my config :

root@7aa46eedf8d4:/usr/src/app/node_modules/lw.comm-server# cat conf.env 
RESET_ON_CONNECT=1
VERBOSE_LEVEL=3
LOG_LEVEL=3

I moved the conf.env to the root /usr/src/app (where the app is ran from) without any change.
Is there something else about logging ?

however, I did notice that the webapp is trying to open websocket on port 8080 that is not open in the image


I did change the Dockerfile and my dockercompose file to expose 8080 but that didn’t change anything (same screenshot).

# end of docker file :
...
EXPOSE 8000 8080
CMD [ "npm", "run", "start-server" ]


# docker compose
... 
services:
  lawerweb4:
    image: laserweb4-8080:latest
    restart: unless-stopped
    ports:
      - 82:8000
      - 8080:8080 
#    devices:
#      - /dev/ttyACM0:/dev/ttyACM0
    volumes:
      - /dev:/dev

any new ideas ?

The ENV file must be named “.env” only, with nothing in front of the dot!

The websocket communication only uses port 8000 by defuault, but you can change the port by adding the following line to the env file:
WEB_PORT=8001 (whatever port you like)

here what I have

Where do I configure the websocket port (on the webapp side)? I havent done anything about this, this is default…

The server connection defines the ip and port for the websocket communication. The default port should be 8000!

thing is 8000 is already taken by some other service… that is the reason I moved to 82

you can do that, aslong as you also reconfigure the server to listen on this port. So create a file named “.env” and add the line “WEB_PORT=82”.

If this does not work, go to config.js (where the defaults are defined) and change the port at the end of line 6 to:
config.webPort = process.env.WEB_PORT || 82;

ok.
I did get the 8000 port out of my way. so I can now use 8000 for laserweb but there is still this web socket to 8080 (!!!???)

image

log still the same :

> laserweb@4.0.998 start-server /usr/src/app
> node node_modules/lw.comm-server/server.js

***************************************************************
        ---- LaserWeb Comm Server 4.0.136 ----        
***************************************************************
  Use  http://172.17.0.3:8000 to connect this server.
 
* Updates: 
  Remember to check the commit log on
  https://github.com/LaserWeb/lw.comm-server/commits/master
  regularly, to know about updates and fixes, and then when ready
  update accordingly by running git pull
 
* Support: 
  If you need help / support, come over to 
  https://plus.google.com/communities/115879488566665599508
***************************************************************
 
App connected! (id=0)
INFO: Requesting Server Config 
App connected! (id=1)
INFO: Requesting Server Config 
App connected! (id=2)
INFO: Requesting Server Config 
App disconnected! (id=0)
App disconnected! (id=0)
App disconnected! (id=0)
App connected! (id=0)
INFO: Requesting Server Config 
App disconnected! (id=0)
App connected! (id=0)
INFO: Requesting Server Config 
App disconnected! (id=0)
App connected! (id=0)
INFO: Requesting Server Config

vu dans webpack.config.js :

'webpack-dev-server/client?http://0.0.0.0:8080'

is it related ?

No, that should only be used for development, when debuging webpack, but not in the app folder, where the “compiled” webpack files are.

Which repo and branch did you use for your install?
For a runtime environment I sugest to use:

This is the server witch also serves the frontend (as webpack in the app folder).