0

I am using Docker Compose, which will run on a Linux tablet in production. I have a container serving up a web GUI. The user will click a "print" button in the GUI, which will result in some kind of request (probably HTTP to Flask in another container, which will maybe forward it to some other container), and that request will result in some data being sent to the printer.

My first step, I can only imagine, is to be able to send data to the printer from inside a Docker container. Any Docker container. I can then use that knowledge, of how to send something to the printer from Docker, to incorporate the printing into my system.

So, that's the infrastructure I'm working with. It can be simplified as simply "I want to print to a printer from a Docker container." I'm working on a Mac, and I can print from the Mac using lp. So I know the connection to the printer is working.

I've tried a few containers, including olbat/cupsd. lpstat -r pretty much always says the Scheduler is running, but lpstat -v always shows that no destinations are set up.

My DevOps guy and I have been banging our heads against the wall all day on this. There are various articles and repos about setting of CUPS in Docker, but they all have holes somewhere, where they say "Use the fooglesplatter to connect to the printer" without telling you what a fooglesplatter is. Or (for a more concrete example) they'll talk about how you set up the CUPS dashboard to add your printer on your local machine, and then say "Voila! You can print!" without telling you what to do in the container. Or they'll refer to a conf file that doesn't exist on my machine. Or something else that leaves us completely baffled.

Can someone who has accomplished this please post (or direct me to) a step-by-step guide that basically treats me like I've never touched a computer before? That assumes no knowledge whatsoever and spells out every step? We are wise Docker users, and my DevOps guy is a much smarter guy than I am, but we are both at a loss.

I know this is a crazy request. Maybe it's not an SO appropriate question. Close it if you must. But we are incredibly stuck and I really hope someone can help us.

Jonathan Tuzman
  • 11,568
  • 18
  • 69
  • 129
  • may have more luck on [serverfault](https://serverfault.com/) – v25 Nov 16 '20 at 23:48
  • I don't have a recipe, but you might try using one of the techniques in [From inside of a Docker container, how do I connect to the localhost of the machine?](https://stackoverflow.com/questions/24319662/from-inside-of-a-docker-container-how-do-i-connect-to-the-localhost-of-the-mach?rq=1) to connect to lpd or CUPS on the host. (Containers need special privileges to access hardware devices, and it's especially weird on MacOS where there's a hidden Linux VM in between.) – David Maze Nov 17 '20 at 00:36
  • @DavidMaze thanks I'll check that out. I think I still need help understanding how to use this information though. Are we maybe talking about treating the printer as a network printer or something? Where it's addressed from its IP address (and that then disregards the fact that it's plugged in locally)? – Jonathan Tuzman Nov 17 '20 at 15:28
  • Essentially, yes. – David Maze Nov 17 '20 at 15:43
  • @DavidMaze thanks. Since I'm not all that experienced with most of the process, your answer definitely points the way, but leaves a lot that I simply don't know. If you are comfortable with some list of steps, even if some of those steps are a black box, I would be extremely appreciative if you would post that recipe as an answer. If one of those steps is something like "Set up the printer this way, although first you'll have to get docker to allow you to access it, which is maybe described in this other SO post", that's still far more knowledge than I have currently. – Jonathan Tuzman Nov 17 '20 at 15:52
  • @JonathanTuzman did you work this out? I have the exact situation. I can print from the host to a remote printer just fine. But inside the docker container, I can't figure out how to get out of the container, to access the print commands on the host (which in turn access a CUPS connected network printer). There is STILL no concrete steps on this out there. – robster Feb 04 '22 at 06:00

0 Answers0