Container doesn't start without a USB tty present, but I use PSU Control

I'd be surprised if I were the only one with this problem, but I didn't find any existing thread or an entry in the FAQ.

I turn my printer on and off via PSU Control (through Home Assistant). This means that the printer isn't on most of the time, especially while the machine is booting up - which in turn means there's no /dev/ttyUSB0 that I could pass in to the docker container, which means it fails to start.

Has anybody found a workaround?

I'm thinking about something like a "dummy /dev/ttyUSB device" that's always present even when the physical device isn't, and switches transparently when a physical device is connected. I haven't found anything to that effect, however.

I've also tried bind mounting /dev/, but for some reason that also doesn't seem to work reliably; starting the container before the printer always resulted in communication timeouts.

Everything is fine, including automatic turning on/off, as long as the octoprint container starts while the printer is connected. The only issue is that it doesn't start unless the device exists, and this seems to be intended behavior.

(I used to run OctoPi, but have since migrated to a different platform than Raspberry Pi, which now also runs other things than Octoprint, hence why I migrated to Docker)

This is one of the drawbacks of running OctoPrint in a docker container. You don't have to do that to run OctoPrint alongside other things or not on a Raspberry Pi, as the setup for docker normally involves harder system configuration. OctoPrint can just be installed directly on your system and run without impacting other services.

To my understanding, you can create some cgroup/udev rules (Assuming you are running Linux) that would do what you are suggesting to make the device 'appear' to always exist. The below YouTube video from the docker maintainer @LongLiveCHIEF describes how you can do it (I'm not sure if there is a different guide somewhere, this is the only thing I know of). Starts at 1:38:25:

1 Like

Awesome, thanks! Will check out, that sounds exactly like what I want.

I know, and I did consider it, but there's a number of other services running all in Docker, and I prefer to have my system as "reproducible" and keep the host OS as barebones as possible. (Once I bite the bullet and check out NixOS or other such systems, that might just be the way forward, though!)