Repository navigation
Install macOS
Running the relay on a Mac is
Experimental. Using a Mac as a client is Tested; see Clients. What the labels mean
The relay is designed for an always-on Linux host or NAS. On a Mac there is a basic obstacle: containers run inside a
Linux VM, and neither Docker Desktop nor Apple's container tool lets that VM send multicast DNS to your LAN, so
iPhones can't discover a relay running there on its own.
| Option | Good for | Status |
|---|---|---|
| Docker Desktop | Trying the relay, developing a printer profile, printing from the same Mac | Testing only |
Apple container + dns-sd |
A Mac that is always on and should serve iPhones | Experimental, untested |
| macOS printing without a container | Mac-only households | Not tested by this project |
Docker Desktop's host networking works at layer 4 inside its VM (Docker docs); multicast doesn't reach your LAN. You can still run the relay, query it and print to it from the Mac itself, which is handy for testing a profile or a vendor PPD.
macOS's own CUPS already listens on localhost:631, so use port 8631 for the relay, inside and outside the container:
docker run -d --name airprint-relay \
-p 127.0.0.1:8631:8631 \
-e CUPS_PORT=8631 \
-e AVAHI_MODE=off \
-e PRINTER_URI=socket://192.0.2.10:9100 \
-e PRINTER_PROFILE=generic-postscript \
ghcr.io/jmoore2333/legacy-printer-airprint-relay:latest
docker logs airprint-relay # "[lpar] ready: ..."
docker exec airprint-relay lpar-status
ipptool -tv ipp://127.0.0.1:8631/printers/legacy-printer get-printer-attributes.test | grep -E 'media-(default|ready)'To print a test page from this Mac, add the queue by address with the helper script from the repository:
CUPS_PORT=8631 scripts/macos/add-relay-queue.sh 127.0.0.1 legacy-printerRemove it later in System Settings › Printers & Scanners, and the container with docker rm -f airprint-relay.
Warning
Experimental and untested end to end. Please report results.
container is Apple's open-source tool for running Linux containers as
lightweight VMs. It needs a Mac with Apple silicon and macOS 26 or later. Containers sit on a private vmnet network on
the Mac and are reachable from outside only through --publish port forwarding
(networking docs); there is no host or bridged
networking, and no multicast to the LAN.
The workaround: run the relay with AVAHI_MODE=off, publish its IPP port on all of the Mac's addresses, and let the
Mac's own Bonjour announce it with dns-sd -P, run by a launchd agent.
flowchart LR
P["iPhone / iPad"] -- "mDNS: finds printer" --> B["Mac's Bonjour<br/>(dns-sd -P, launchd agent)"]
P -- "IPP to Mac IP :8631" --> F["--publish 0.0.0.0:8631"]
F --> R["relay container<br/>AVAHI_MODE=off, CUPS_PORT=8631"]
R -- "socket 9100" --> L["Legacy printer"]
Short version (the full, copy-paste steps are in
examples/macos-apple-container):
-
Install
containerfrom its releases page and runcontainer system start. -
Reserve a fixed IP address for the Mac in your router (
192.0.2.20here). -
Run the relay:
container volume create lpar-cups-state container volume create lpar-cups-spool container run -d --name airprint-relay \ --publish 0.0.0.0:8631:8631 \ -e CUPS_PORT=8631 -e AVAHI_MODE=off -e ALLOWED_NETWORKS=192.0.2.0/24 \ -e PRINTER_URI=socket://192.0.2.10:9100 -e PRINTER_PROFILE=generic-postscript -e PAPER_SIZE=Letter \ -v lpar-cups-state:/etc/cups -v lpar-cups-spool:/var/spool/cups \ ghcr.io/jmoore2333/legacy-printer-airprint-relay:latest
ALLOWED_NETWORKSis your LAN subnet, so CUPS accepts jobs however the port forwarding presents the clients. -
Check that another computer on the LAN can reach it:
curl -s -o /dev/null -w '%{http_code}\n' http://192.0.2.20:8631/printers/legacy-printershould print200. Apple's documentation describes--publishwith loopback addresses; whether0.0.0.0reaches the LAN on your Mac is exactly what this step checks. -
Copy the launchd agent template
io.github.jmoore2333.lpar-advertise.plistto~/Library/LaunchAgents/, edit the name, port, proxy host name, Mac IP and TXT values (compare withcontainer exec airprint-relay lpar-status), then load it:launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/io.github.jmoore2333.lpar-advertise.plist
The agent runs
dns-sd -P "<name>" _ipp._tcp,_universal local 8631 airprint-relay.local 192.0.2.20 rp=… pdl=… URF=… …. Use a new host name for the advertisement, not the Mac's own name. -
Verify from any Mac:
dns-sd -B _ipp._tcp,_universallists the printer anddns-sd -L "<name>" _ipp._tcpshowsairprint-relay.local.:8631with the TXT record. Then print from an iPhone.
-
Static advertisement. The TXT record (paper, duplex, colour, queue path) is typed into the plist. Change
PAPER_SIZE,DUPLEX,COLOR,QUEUE_NAMEor the port, and you must update the plist. On Linux the relay's own Avahi keeps this in sync automatically. -
No restart policy.
containerhas no--restartoption. After a reboot, runcontainer system startandcontainer start airprint-relay. -
Fixed Mac IP, because
dns-sd -Pannounces an address, not the Mac's changing one. - The Mac must stay awake to accept jobs, and the macOS firewall must allow incoming connections.
- Not validated: LAN reachability of published ports, how clients appear to CUPS, and iOS behaviour with a proxy advertisement have not been tested.
If the always-on machine is a Mac, macOS can often do the job without any container:
- Add the legacy printer directly: System Settings › Printers & Scanners › Add Printer, Scanner or Fax… › IP,
address
192.0.2.10, protocol HP Jetdirect - Socket, and a PostScript driver (for example Generic PostScript Printer). Macs can now print to it. - Share it: System Settings › General › Sharing › Printer Sharing, and tick the printer. Other Macs see it.
iPhones and iPads look for the _universal Bonjour subtype. macOS's printer sharing advertises shared printers with
the _cups subtype by default (see man cupsd.conf, BrowseDNSSDSubTypes), so iOS may not list a shared legacy
printer. The third-party AirPrint Bridge project addresses exactly
that by adding the missing advertisement with dns-sd and a launchd job. Neither approach is tested by this project.
- Clients: adding the relay on a Mac that is a client.
- Networking: Host vs Macvlan: why host networking matters.
- Install with Docker Compose on Linux: the recommended kind of host.
legacy-printer-airprint-relay · MIT License · Report an issue · Not affiliated with Apple, Xerox or Synology. AirPrint is a trademark of Apple Inc.