docker-octoprint icon indicating copy to clipboard operation
docker-octoprint copied to clipboard

Add instructions for passing USB port to docker container

Open Have-Purple opened this issue 5 years ago • 19 comments

Suggest adding instructions to to identify the USB port being used and then passing this device into the container.

With the pi connected to the printer via usb ls /dev | grep tty

This should return a long list of 'tty' The one we need is found at the end of the list and is probably ttyUSB0 if no other USB devices are plugged in.

In order to use this ttyUSB0 add this to your docker run command

docker run -device /dev/ttyUSB0:/dev/ttyUSB0 .....

Now octoprint can detect the the USB port and connect to the printer.

Have-Purple avatar Jan 19 '20 20:01 Have-Purple

Hello,

I have an asustor machine on which I installed a dsm system, from synology, in which I installed the graphical application "docker", and I don't see how to pass this parameter. Whether to put it in environment variables or elsewhere. maybe in the octoprint.json ... i don't know. parametre

vlotho avatar Feb 12 '20 07:02 vlotho

Hello,

I have an asustor machine on which I installed a dsm system, from synology, in which I installed the graphical application "docker", and I don't see how to pass this parameter. Whether to put it in environment variables or elsewhere. maybe in the octoprint.json ... i don't know. parametre

I don't use docker on a DSM system but a quick search reveals that there should be an "advanced settings" tab where you can configure more docker settings.

see> https://www.baitando.de/it/2019/09/22/using-docker-on-synology-nas

Have-Purple avatar Feb 12 '20 19:02 Have-Purple

DSM docker UI application does not have option to set "device".

But you still can do this by following steps:

  1. create "octoprint" container with all settings you need (volumes, ports etc)
  2. select "Settings" -> "Export" and export docker container configuration JSON to local computer
  3. open exported JSON in any editor
  4. find string
"devices" : null,

and replace it with

   "devices" : [
       {
           "pathOnHost": "/dev/ttyUSB0",
           "PathInContainer": "/dev/ttyUSB0",
           "CgroupPermissions": "rwm"
       }
   ],
  1. Import JSON file back to DSM docker UI

P.S. Also I found that my "/dev/ttyUSB0" has "crw-------" permission, and can't be accessed inside docker by octoprint application. So I have to manually set to "crw-rw-rw-" with

chmod a+rw /dev/ttyUSB0

s1mb1o avatar May 16 '20 23:05 s1mb1o

Suggest adding instructions to to identify the USB port being used and then passing this device into the container.

With the pi connected to the printer via usb ls /dev | grep tty

This should return a long list of 'tty' The one we need is found at the end of the list and is probably ttyUSB0 if no other USB devices are plugged in.

In order to use this ttyUSB0 add this to your docker run command

docker run -device /dev/ttyUSB0:/dev/ttyUSB0 .....

Now octoprint can detect the the USB port and connect to the printer.

Hi i installed everything and it works. unfortunately I can't enable the usb and launching the command (pi4): docker: invalid reference format: repository name must be lowercase. See 'docker run --help'.

some advice?

armandoss avatar Jun 01 '20 22:06 armandoss

DSM docker UI application does not have option to set "device".

But you still can do this by following steps:

  1. create "octoprint" container with all settings you need (volumes, ports etc)
  2. select "Settings" -> "Export" and export docker container configuration JSON to local computer
  3. open exported JSON in any editor
  4. find string
"devices" : null,

and replace it with

   "devices" : [
       {
           "pathOnHost": "/dev/ttyUSB0",
           "PathInContainer": "/dev/ttyUSB0",
           "CgroupPermissions": "rwm"
       }
   ],
  1. Import JSON file back to DSM docker UI

P.S. Also I found that my "/dev/ttyUSB0" has "crw-------" permission, and can't be accessed inside docker by octoprint application. So I have to manually set to "crw-rw-rw-" with

chmod a+rw /dev/ttyUSB0

This allowed me to get Octopi working with Docker on my Synology NAS, thanks! On that hardware, the interface is /dev/ttyACM0

Unfortunately I can't customize the Octoprint port, so had to manually enter it into LulzBot Cura, but otherwise everything is working awesome!

epheterson avatar Jan 26 '21 21:01 epheterson

DSM docker UI application does not have option to set "device". But you still can do this by following steps:

  1. create "octoprint" container with all settings you need (volumes, ports etc)
  2. select "Settings" -> "Export" and export docker container configuration JSON to local computer
  3. open exported JSON in any editor
  4. find string
"devices" : null,

and replace it with

   "devices" : [
       {
           "pathOnHost": "/dev/ttyUSB0",
           "PathInContainer": "/dev/ttyUSB0",
           "CgroupPermissions": "rwm"
       }
   ],
  1. Import JSON file back to DSM docker UI

P.S. Also I found that my "/dev/ttyUSB0" has "crw-------" permission, and can't be accessed inside docker by octoprint application. So I have to manually set to "crw-rw-rw-" with

chmod a+rw /dev/ttyUSB0

This allowed me to get Octopi working with Docker on my Synology NAS, thanks! On that hardware, the interface is /dev/ttyACM0

Unfortunately I can't customize the Octoprint port, so had to manually enter it into LulzBot Cura, but otherwise everything is working awesome!

Hi Guys so basically I am a bit lost here... octoprint itself is running in my docker on my DSM. i connected the printer Anycubic 4Max Pro to the front port and to the back one. When turning Serial and Baud to automatic i get the error offline no more candidates to test indicating the applications has not found my printer. when Shh into my dsm i can find the usb device Silicon Labs CP2102N USB to UART Bridge Controller.

in Octoprint i have the options for ttyS0 -S3 i have edited these directories as well as tried other names like USB3 with chmod but could not get it to work. what am i doing wrong? BR

MaOlaf avatar Jan 29 '21 23:01 MaOlaf

This allowed me to get Octopi working with Docker on my Synology NAS, thanks! On that hardware, the interface is /dev/ttyACM0 Unfortunately I can't customize the Octoprint port, so had to manually enter it into LulzBot Cura, but otherwise everything is working awesome!

Hi Guys so basically I am a bit lost here... octoprint itself is running in my docker on my DSM. i connected the printer Anycubic 4Max Pro to the front port and to the back one. When turning Serial and Baud to automatic i get the error offline no more candidates to test indicating the applications has not found my printer. when Shh into my dsm i can find the usb device Silicon Labs CP2102N USB to UART Bridge Controller.

in Octoprint i have the options for ttyS0 -S3 i have edited these directories as well as tried other names like USB3 with chmod but could not get it to work. what am i doing wrong? BR

Hey, first you need to determine what the interface is on the Synology.

  1. Optionally boot the Synology with nothing connected to any USB port.
  2. Login via SSH and do ls /dev | grep tty
  3. Plugin the USB with printer powered on and do ls /dev | grep tty once more.
  4. There should be a new interface, find something that looks like /dev/ttyACM0 or /dev/ttyUSB0
  5. Use this interface in the steps from @s1mb1o

epheterson avatar Jan 29 '21 23:01 epheterson

Has anyone got a work around for DSM 7, which currently does not include support for /dev/ttyACM0 or /dev/ttyUSB0 via docker? If not I'd advice folks to stay on DSM 6 for now.

glan avatar Aug 04 '21 17:08 glan

Has anyone got a work around for DSM 7, which currently does not include support for /dev/ttyACM0 or /dev/ttyUSB0 via docker? If not I'd advice folks to stay on DSM 6 for now.

I am working on the same issue... Cannot get the /dev/ttyUSB0 forwarded to docker via the method described above.. I did get the serial USB driver from Jadahl working, but there it stops. Any time I try to upload a new settings .json file, the 'devices' section is ignored.. Wish I'd stayed at DSM6 :( If anyone finds a solution, very keen to hear it!

piano-thomas avatar Aug 26 '21 20:08 piano-thomas

@piano-thomas FWIW I did get it forwarded, using Portainer ~~, and it discovers the device and attempts to connect but fails. I feel like DSM 7 is EOL for Octoprint unless something else comes out to try.~~

Edit: These steps do work, as long as you first do: https://github.com/robertklep/dsm7-usb-serial-drivers

To get this far, I did these steps:

  1. Install missing USB drivers using steps at: https://github.com/robertklep/dsm7-usb-serial-drivers
  2. Plug in and power on 3D printer. Discover interface by browsing /dev/tty* and enable permissions with: chmod a+rw /dev/ttyACM0
  3. Set up Octoprint in Docker w/out devices configured properly.
  4. Setup Portainer in Docker.
  5. Use Portainer to view Octoprint container, click 'Duplicate/Edit' and for the new container add the device mapping under 'Runtime & Resources'. Above the 'Advanced container settings' choose 'Deploy the container' and overwrite the original.
  6. Start Octoprint ~~, see the interface appear, try to connect – Fail.~~

epheterson avatar Dec 14 '21 01:12 epheterson

Hey all, I managed to get it working by following the steps here: https://github.com/robertklep/dsm7-usb-serial-drivers

epheterson avatar Dec 21 '21 01:12 epheterson

@piano-thomas FWIW I did get it forwarded, using Portainer, and it discovers the device and attempts to connect but fails. I feel like DSM 7 is EOL for Octoprint unless something else comes out to try.

To get this far, I did these steps:

  1. Setup Task Scheduler On Boot task to run as root:
/sbin/modprobe usbserial
/sbin/modprobe ftdi_sio
/sbin/modprobe cdc-acm
insmod /lib/modules/usbserial.ko
insmod /lib/modules/ftdi_sio.ko
insmod /lib/modules/cdc_acm.ko
chmod 777 /lib/modules/usbserial.ko
chmod 777 /lib/modules/ftdi_sio.ko
chmod 777 /lib/modules/cdc-acm.ko
  1. Plug in and power on 3D printer. Discover interface by browsing /dev/tty* and enable permissions with: chmod a+rw /dev/ttyACM0
  2. Set up Octoprint in Docker w/out devices configured properly.
  3. Setup Portainer in Docker.
  4. Use Portainer to view Octoprint container, click 'Duplicate/Edit' and for the new container add the device mapping under 'Runtime & Resources'. Above the 'Advanced container settings' choose 'Deploy the container' and overwrite the original.
  5. Start Octoprint, see the interface appear, try to connect – Fail.

I did get the dsm7 drivers to work using the steps described by @robertklep, however the forwarding is still a mystery to me :(.

piano-thomas avatar Dec 27 '21 15:12 piano-thomas

@epheterson I just got octoprint working with DSM7 and docker container! Using container in privilege mode was the clue. Somehow the docker container couldn't access the /dev folder and detect the printer. If your printer is visible in the /dev list you should be able to run octoprint in docker with privilege mode and use it without Portainer.

piano-thomas avatar Dec 27 '21 16:12 piano-thomas

@epheterson I just got octoprint working with DSM7 and docker container! Using container in privilege mode was the clue. Somehow the docker container couldn't access the /dev folder and detect the printer. If your printer is visible in the /dev list you should be able to run octoprint in docker with privilege mode and use it without Portainer.

Is there anyway I can do this without running my container in privilege mode? Really would like to know how I can access /dev without having to run in privilege mode

harry71019 avatar Jan 16 '22 19:01 harry71019

@harry71019 if you pass the specific device file(s) to the container (--device=/dev/foo:/dev/foo) you don't need privileged mode, but if I understand correctly (not a user), octoprint may require full access to /dev and not just to specific files.

robertklep avatar Jan 17 '22 06:01 robertklep

@epheterson I just got octoprint working with DSM7 and docker container! Using container in privilege mode was the clue. Somehow the docker container couldn't access the /dev folder and detect the printer. If your printer is visible in the /dev list you should be able to run octoprint in docker with privilege mode and use it without Portainer.

Is there anyway I can do this without running my container in privilege mode? Really would like to know how I can access /dev without having to run in privilege mode

I can confirm my setup does not have privileged mode enabled, and Octoprint is working fine. You will have to manually forward the device like I mentioned in my earlier post, or when creating the container as @robertklep mentioned.

epheterson avatar Jan 19 '22 01:01 epheterson

@epheterson @robertklep Thank you for both of your replies. Do you know how I can pass the --device using the docker GUI in DSM? Or am I better off with setting up portainer and creating a new container and passing the devices in.

harry71019 avatar Jan 19 '22 02:01 harry71019

@epheterson @robertklep Thank you for both of your replies. Do you know how I can pass the --device using the docker GUI in DSM? Or am I better off with setting up portainer and creating a new container and passing the devices in.

It's not possible to pass these devices with DSM UI, I suspect the UI is intentionally limited / simplified. You can avoid Portainer by creating your Docker container via CLI using the --device argument, or you can install Portainer and adjust settings on an existing (or new) container.

epheterson avatar Jan 19 '22 02:01 epheterson

Thank you for your clarification, I guess I'll look into portainer and set it up.

harry71019 avatar Jan 19 '22 02:01 harry71019