Skip to content

Install macOS

github-actions[bot] edited this page Dec 5, 2026 · 1 revision

Run the relay on a Mac

Status: Experimental 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

Option 1: Docker Desktop (testing only)

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-printer

Remove it later in System Settings › Printers & Scanners, and the container with docker rm -f airprint-relay.

Option 2: Apple's container tool with Bonjour from the Mac

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"]
Loading

Short version (the full, copy-paste steps are in examples/macos-apple-container):

  1. Install container from its releases page and run container system start.

  2. Reserve a fixed IP address for the Mac in your router (192.0.2.20 here).

  3. 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_NETWORKS is your LAN subnet, so CUPS accepts jobs however the port forwarding presents the clients.

  4. 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-printer should print 200. Apple's documentation describes --publish with loopback addresses; whether 0.0.0.0 reaches the LAN on your Mac is exactly what this step checks.

  5. Copy the launchd agent template io.github.jmoore2333.lpar-advertise.plist to ~/Library/LaunchAgents/, edit the name, port, proxy host name, Mac IP and TXT values (compare with container 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.

  6. Verify from any Mac: dns-sd -B _ipp._tcp,_universal lists the printer and dns-sd -L "<name>" _ipp._tcp shows airprint-relay.local.:8631 with the TXT record. Then print from an iPhone.

Trade-offs

  • Static advertisement. The TXT record (paper, duplex, colour, queue path) is typed into the plist. Change PAPER_SIZE, DUPLEX, COLOR, QUEUE_NAME or the port, and you must update the plist. On Linux the relay's own Avahi keeps this in sync automatically.
  • No restart policy. container has no --restart option. After a reboot, run container system start and container start airprint-relay.
  • Fixed Mac IP, because dns-sd -P announces 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.

Option 3: no container (macOS printing)

If the always-on machine is a Mac, macOS can often do the job without any container:

  1. 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.
  2. 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.

Related

Clone this wiki locally