Run a CUPSD print server on Raspberry Pi

I have an old HP 4050N. For a variety of reasons, I want to have it behind a print server instead of having my laptops print directly to it. Here’s how I set that up.

Prerequisites

  • A Raspberry Pi (or honestly any linux box) running docker. I like the Raspberry Pi and Odroid HC2 for this sort of thing because they are very low power.
  • A printer supported by the CUPS project.

Setup

Setup is easy. There are several docker images out there you can use, I made one (the source is on github at unixorn/docker-cupsd) because I wanted one that was multi-architecture - my image has AMD64, ARM7 and ARM64 artchitectures all baked into the same image so you don’t have to change the image label based on what system you’re running it on. It works fine on (at least) Raspberry Pi, Odroids and Intel servers.

The unixorn/cupsd docker image is a bit on the large side because I crammed a lot of printer drivers into it, you may want to look for images that only support single printer families.

We’re going to store printers.conf in a directory outside the container so that we don’t lose our printer configuration every time we upgrade our container.

I run the cupsd server on an Odroid HC2 because I have /var/lib/docker on the 2TB drive attached to it. I could have put it on one of the Raspberry Pis in the cluster, but didn’t want it spooling print jobs and causing excessive wear on the rPi’s microSD card.

  1. Make a directory to store your printer configuration. We’ll use /docker/cupsd/etc
  2. export CUPSD_DIR='/docker/cupsd/etc'
  3. touch $CUPSD_DIR/printers.conf
  4. Run the cupsd server with
sudo docker run -d --restart unless-stopped \
  -p 631:631 \
  --privileged \
  -v /var/run/dbus:/var/run/dbus \
  -v /dev/bus/usb:/dev/bus/usb \
  -v $CUPSD_DIR/printers.conf:/etc/cups/printers.conf \
  unixorn/cupsd

You can now connect to http://SERVER:631 and add printers using the web UI.

When adding the printers to your Mac, select Internet Printing Protocol and put in the IP or DNS name of your print server machine.

The queues are printers/printername, not printername.

Buy me a coffeeBuy me a coffee