nunofgs / docker-octoprint

Dockerfile to set up Octoprint with x86, armv6, armv7 and arm64 support!
https://hub.docker.com/r/nunofgs/octoprint/
GNU Affero General Public License v3.0
58 stars 32 forks source link

Add instructions for passing USB port to docker container #37

Open Have-Purple opened 4 years ago

Have-Purple commented 4 years ago

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.

vlotho commented 4 years ago

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

Have-Purple commented 4 years ago

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

s1mb1o commented 4 years ago

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"
       }
    ],
  5. 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
armandoss commented 4 years ago

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?

epheterson commented 3 years ago

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!

MaOlaf commented 3 years ago

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

epheterson commented 3 years ago

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
glan commented 2 years ago

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.

piano-thomas commented 2 years ago

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!

epheterson commented 2 years ago

@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 commented 2 years ago

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

piano-thomas commented 2 years ago

@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 commented 2 years ago

@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.

harry71019 commented 2 years ago

@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

robertklep commented 2 years ago

@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.

epheterson commented 2 years ago

@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.

harry71019 commented 2 years ago

@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.

epheterson commented 2 years ago

@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.

harry71019 commented 2 years ago

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