Open 0elek opened 6 months ago
Hi,
Sorry about that. I've been meaning to reply, but I haven't had time to really look into it. But you are correct, I have also experienced this in the past.
The container doesn't always recognise the printer, after the printer is turned OFF then ON. I had tried to avoid this by passing the entire /dev/usb
device, instead of a specific port. But it doesn't always work as intended.
I typically have a push-button connected to my RPi's gpio that just restarts this container.
I'll try to take a look at the issue in detail and see what can be done. Can't give you a timeline, but I'll definitely take a look at it. It's something I need to fix anyway. Thanks for reminding me.
This is happening with me too.
It is possible to add an workaround, where the printer USB events are listened and if an "on/off" event occur then restart the docker-CUPS service?
This could work, but then, if the a printer's power is turned off, and it does not come back on, you could potentially get stuck in a restart-loop. Plus I am not sure how you would run a daemon like that unless you just run a checking script at regular intervals, systemd is typically not used in containers iirc.
You are right, this could lead to other issues...
About the restart-loop, my only idea is to create a variable (linked to a checkbox) where you need to be sure if you want to enable it or not, knowing the risks.
i think first we should find out why does to container loses the usb device, cups on bare metal can handle power state change
We managed to put a udev rule to monitor USB changes and restart the container. It not the solution for the "why the docker/container loses the connectivity to the device", but works for our needs.
If someone needs it, I detailed the solution here: https://superuser.com/q/1849642/853051
Yeah, that was my first thought too, but that's a solution outside the container. So I didn't want to make that the go to method. But yeah, that's a fix for now.
I have an idea I want to explore within the container, for restarting the cups service. I will try it tomorrow and keep you posted.
Alright, I will be watching your project.
I have zero to none experience with docker, but if I learn something, I will share here.
this looks helpful but i think we need to run this outside of the container,
Also privileged: true
seems to be able to forward the usb after on/off but the id changes,
so adding a udev rule(inside the container) should work then?
But for that we need somehow know some information like manufacturer and device id.
which we can get from the printers.conf.
this looks like a way if somebody wants to fix it.
Currently, when the printer is turned off, cups is unable to detect it when I turn it back on.
It works fine when i restart the docker container, so I think its having trouble finding the /dev/usb/[], since it changes when the printer is reconnected container host's OS.
Not sure that I set up something wrong, or its an issue with the container.
docker-compose.yml:
data/printers.conf: