How to Print from a Docker Container via Host CUPS Passthrough
Joe B.
Reviewed for technical accuracy
Specialities: Linux, Docker, CUPS/IPP Everywhere, Networking, DevOps
Enable printing from Docker — CUPS domain socket bind mount, IPP to host, USB passthrough
Quick answer: the accepted fix
Accepted fix for Docker printing via host CUPS: bind-mount /run/cups/cups.sock into the container, set ServerName /run/cups/cups.sock (or CUPS_SERVER), install cups-client, and ensure the container user can access the socket. Alternative: use IPP to the host via host.docker.internal:631 or --network=host (dev only).
When to use socket vs IPP (driverless, 631/tcp, host-gateway)
Socket passthrough is best for security and performance — the container talks to host CUPS locally. IPP is flexible for multi-container stacks: set ServerName host.docker.internal:631, keep CUPS bound to 127.0.0.1, and avoid publishing 631 externally. Both approaches keep drivers/PPDs on the host, simplifying docker container printing.
How to verify container-to-host CUPS printing
Inside the container, run lpstat -p and lpstat -a; you should see host queues. Print a multi-page PDF with lp -d <queue> file.pdf. If it fails, confirm the socket path, group membership (lp/cups), and whether CUPS requires authentication. For IPP, test curl http://host.docker.internal:631/printers/ (from the container).
Docker → CUPS passthrough — quick tips
Bind-mount the CUPS socket or talk IPP to the host; keep drivers on the host.
Quick path: mount /run/cups/cups.sock → add cups-client → set ServerName/CUPS_SERVER → map user IDs for socket access → for IPP use host-gateway alias. Avoid publishing 631 on public interfaces. This is the most reliable way to enable container printing.
Disclaimer: This information is AI-generated and intended for general guidance only. For advice specific to your environment, please consult a verified expert on Whizz-Tech before making decisions.
Getting Started Is Easy
Ask for help, 24/7
Members enjoy round-the-clock access to 12,000+ verified Experts, including tech support, mechanics, vets, and more.
Expert will respond in minutes
We match you with an Expert who specializes in your situation. Talk, text, or chat — whichever you prefer.
Save time & money
No scheduling hassles or expensive consults. Membership can save you significant time and money each month.
FAQ
Is socket passthrough better than IPP for Docker printing?
Yes for production: mount /run/cups/cups.sock and point ServerName to it. No network port exposure, fewer failure modes. IPP is fine when you need discovery or multiple containers.
How do I let a container access the CUPS socket?
Bind-mount the socket, install cups-client, and ensure the container user has access (map UID/GID or join lp/cups group). Adjust AppArmor/SELinux if they block the mount.
How do I reach host CUPS from a container via IPP?
Add host.docker.internal with --add-host=host-gateway and set ServerName host.docker.internal:631. Alternatively, use --network=host on dev machines.
Do I need printer drivers inside containers?
No. Keep drivers/PPDs on the host CUPS (prefer IPP Everywhere). Containers only need cups-client to submit jobs.
| Symptom | Likely cause | Quick fix |
|---|---|---|
| Container can’t see printers | No socket/IPP configured | Mount /run/cups/cups.sock or set ServerName host.docker.internal:631 |
| client-error-not-authorized | Socket perms or CUPS auth | Map UID/GID; join lp/cups; set credentials |
| IPP connection refused | CUPS bound to localhost only | Use host-gateway alias or socket passthrough; avoid exposing 631 |
| USB prints from host but not container | App targets wrong server | Point container to host CUPS via socket/IPP; no USB passthrough needed |
Step-by-step (Docker → host CUPS)
- Install cups-client inside the container image or at runtime.
- Bind-mount
/run/cups/cups.sockand setServerName /run/cups/cups.sock(orCUPS_SERVER). - Map user IDs/groups so the container can access the socket; verify with
lpstat -p. - Alternative: add
host.docker.internal:host-gatewayand setServerName host.docker.internal:631.
Note for mixed environments (Kubernetes/Compose)
- For k8s, use a hostPath to mount the CUPS socket into the pod and a projected
client.confConfigMap. - For multi-service Compose stacks, centralize printing via one “print-client” service that other containers call.
Sources
Filed under: macOS printing & CUPS
Related articles
- Can print test page but Word/Chrome/Browser won’t print — app-specific fix (Windows/macOS)
- Fedora PDF background missing — poppler flag
- Ubuntu sandboxed PDF viewer wrong color — Ghostscript route (print/render)
- CUPS Bad Request or TLS Error on Linux — What's Breaking It and How to Fix It
- Linux cups-browsed gives wrong PPD — force assign (without breaking auto-discovery)
- macOS Photos Book Export Has Blurry Text — What's Lowering the Quality and How to Get Sharp Results
- macOS Adobe apps only print grayscale — ICC pipeline force fix
- macOS cannot print envelopes — tray override CAPS fix