Open Ed1ks opened 1 year ago
I'm running into similar issues as you, were you ever able to figure it out?
Here's the output of my serial/by-id command
$ ls /dev/serial/by-id/
usb-Klipper_stm32g0b1xx_43004E001750425938323120-if00
Sadly I still cant get it to work
@Ed1ks you could try mounting the entire dev folder as a volume.
You currently have - '/dev:/dev'
in your devices mounting, but AFAIK that isn't supported. Only specific devices can be mounted, not the whole folder, and you can't use wildcards either.
But what you can do is mount the /dev folder as a volume. This means your container can see all your host devices, but it can't access them because it doesn't have permissions. I haven't yet figured out how to give permissions to certain devices, but my workaround at the moment is to give permissions to all devices with privileged: true (which you are already doing).
So to recap, this is what I've done: In docker-compose: privileged: true volumes: - /dev:/dev
In klipper config: [mcu] serial: /dev/serial/by-id/usb-Klipper_stm32f103xe_37FFD9054246383416870857-if00
Here's another approach. This one doesn't mount the entire devices folder, it just mounts the printer.
in docker-compose: privileged: true devices:
in klipper config: [mcu] serial: /dev/ttyUSB0
This has the advantage of being more secure (your container can't access other host devices) but has the disadvantage of failing on container startup if the printer isn't connected.
A final, most secure and most robust option. Mounts all devices, but only gives access to hardware. Privileged mode isn't needed.
services:
klipper:
image: dimalo/klipper-moonraker
privileged: false #not needed now
device_cgroup_rules:
- 'c *:* rmw' #this gives the container permission to access hardware
build:
dockerfile: ./klipper/Dockerfile
context: .
cap_add:
- SYS_NICE
container_name: klipper
ports:
- 7125:7125
restart: unless-stopped
volumes:
- gcode_files:/home/klippy/printer_data/gcodes
- ./config:/home/klippy/printer_data/config
- moonraker_data:/home/klippy/.moonraker_database
- /dev:/hostdevices # mount host devices inside the container without permissions
Here's another approach. This one doesn't mount the entire devices folder, it just mounts the printer.
in docker-compose: privileged: true devices: - /dev/serial/by-id/usb-Klipper_stm32f103xe_37FFD9054246383416870857-if00:/dev/ttyUSB0
in klipper config: [mcu] serial: /dev/ttyUSB0
This has the advantage of being more secure (your container can't access other host devices) but has the disadvantage of failing on container startup if the printer isn't connected.
This is the one that worked for me. Thank you!
I am failing to connect to the printer. After following the guide and testing several thing i now hope someone has an idea how to fix this problem. My system is an Raspberry pi 4 8gb with rocky linux and docker. Another SD-Card with klipper and mainsailOS installed barebones works perfect, but this setup with Docker cant establish the connection to the printer. It always returns the error "mcu 'mcu': Unable to connect" and quits.
This is my current docker-compose file (yes it has to many parameters, but these result from testing)
Some information for the USB Port:
I added the container log and the printer.cfg (both as txt)
klipper_logs.txt printer.cfg.txt