Skip to content

Commit 9d37cd4

Browse files
author
Roger Rumao
committed
Add readme
1 parent 85fc7ae commit 9d37cd4

File tree

1 file changed

+123
-0
lines changed

1 file changed

+123
-0
lines changed

README.md

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# AirPrint bridge for your local printers
2+
3+
[![Docker Image Version (latest semver)](https://img.shields.io/docker/v/rogerrum/cups-airprint)](https://hub.docker.com/r/rogerrum/cups-airprint/tags)
4+
[![license](https://img.shields.io/github/license/rogerrum/cups-airprint)](https://github.com/rogerrum/cups-airprint/blob/main/LICENSE)
5+
[![DockerHub pulls](https://img.shields.io/docker/pulls/rogerrum/cups-airprint.svg)](https://hub.docker.com/r/rogerrum/cups-airprint/)
6+
[![DockerHub stars](https://img.shields.io/docker/stars/rogerrum/cups-airprint.svg)](https://hub.docker.com/r/rogerrum/cups-airprint/)
7+
[![GitHub stars](https://img.shields.io/github/stars/rogerrum/cups-airprint.svg)](https://github.com/rogerrum/cups-airprint)
8+
[![Contributors](https://img.shields.io/github/contributors/rogerrum/cups-airprint.svg)](https://github.com/rogerrum/cups-airprint/graphs/contributors)
9+
[![Paypal](https://img.shields.io/badge/donate-paypal-00457c.svg?logo=paypal)](https://www.paypal.com/donate/?business=CRVGAN4YGG9KL&no_recurring=0&item_name=rogerrum&currency_code=USD)
10+
11+
12+
13+
## Purpose
14+
Run a container with CUPS and Avahi (mDNS/Bonjour) so that local printers
15+
on the network can be exposed via AirPrint to iOS/macOS devices.
16+
17+
I'm using it on my Kube cluster with my old brother printer to use it as airprint. The local Avahi will be utilized for advertising the printers on the network.
18+
19+
I started with the base from https://github.com/DrPsychick/docker-cups-airprint and extended it use the latest ubuntu version and use Brother printer drivers.
20+
21+
## Requirements
22+
* you must have CUPS drivers available for your printer (Brother)
23+
* If you have multiple subnets then make sure mDNS is turned on your router to support airprint
24+
25+
## Configuration
26+
27+
### Variables overview
28+
Important! Docker environment variables only support single line without double quotes!
29+
```shell script
30+
CUPS_ADMIN_USER=${CUPS_ADMIN_USER:-"admin"}
31+
CUPS_ADMIN_PASSWORD=${CUPS_ADMIN_PASSWORD:-"secr3t"}
32+
CUPS_WEBINTERFACE=${CUPS_WEBINTERFACE:-"yes"}
33+
CUPS_SHARE_PRINTERS=${CUPS_SHARE_PRINTERS:-"yes"}
34+
CUPS_REMOTE_ADMIN=${CUPS_REMOTE_ADMIN:-"yes"} # allow admin from non local source
35+
CUPS_ACCESS_LOGLEVEL=${CUPS_ACCESS_LOGLEVEL:-"config"} # all, access, config, see `man cupsd.conf`
36+
CUPS_LOGLEVEL=${CUPS_LOGLEVEL:-"warn"} # error, warn, info, debug, debug2 see `man cupsd.conf`
37+
CUPS_ENV_DEBUG=${CUPS_ENV_DEBUG:-"no"} # debug startup script and activate CUPS debug logging
38+
CUPS_IP=${CUPS_IP:-$(hostname -i)} # no need to set this usually
39+
CUPS_HOSTNAME=${CUPS_HOSTNAME:-$(hostname -f)} # no need to set this usually -> allows accessing cups via name: https://cups.domain:631/
40+
# pass the server cert/key via env in one line each, i.e. CUPS_SSL_CERT=---- BEGIN CERT ...\none\nline\nseparated\nby\nbackslash\nnewline
41+
CUPS_SSL_CERT=${CUPS_SSL_CERT:-""}
42+
CUPS_SSL_KEY=${CUPS_SSL_KEY:-""}
43+
# avahi configuration options
44+
AVAHI_INTERFACES=${AVAHI_INTERFACES:=""}
45+
AVAHI_IPV6=${AVAHI_IPV6:="no"}
46+
AVAHI_REFLECTOR=${AVAHI_REFLECTOR:="no"}
47+
AVAHI_REFLECT_IPV=${AVAHI_REFLECT_IPV:="no"}
48+
```
49+
50+
### Add printer through ENV
51+
Set any number of variables which start with `CUPS_LPADMIN_PRINTER`. These will be executed at startup to set up printers through `lpadmin`.
52+
```shell script
53+
CUPS_LPADMIN_PRINTER1=lpadmin -p brother -D 'Brother HL2270 printer' -m 'HL2270DW.ppd' -v lpd://<printer-host>/BINARY_P1
54+
CUPS_LPADMIN_PRINTER1_ENABLE=cupsenable brother
55+
CUPS_LPADMIN_PRINTER1_ACCEPT=cupsaccept brother
56+
CUPS_LPADMIN_PRINTER2=lpadmin -p second -D 'another' -m everywhere -v ipp://myhost/second
57+
CUPS_LPADMIN_PRINTER3=lpadmin -p third -D 'samba printer' -m '..the right driver string...' -o PageSize=A4 -v smb://user:pass@host/printer
58+
```
59+
60+
### Configure AirPrint
61+
Nothing to do, it will work out of the box (once you've added printers)
62+
* If you have multiple subnets then make sure mDNS is turned on your router to support airprint across the entire network.
63+
64+
### Ports:
65+
* `631`: the TCP port for CUPS must be exposed
66+
67+
## Docker Run
68+
To simply do a quick and dirty run of the cups/airprint container:
69+
```
70+
docker run \
71+
-d --rm \
72+
--net=host \
73+
-e CUPS_WEBINTERFACE="yes" \
74+
-e CUPS_REMOTE_ADMIN="yes" \
75+
--name cups \
76+
rogerrum/cups-airprint
77+
78+
```
79+
To stop the container simply run:
80+
```
81+
$ docker stop cups
82+
```
83+
To remove the conainer simply run:
84+
```
85+
$ docker rm cups
86+
```
87+
**WARNING**: Be aware that deleting the container (i.e. `cups` in the example)
88+
will permanently delete the data that `docker volume` is storing for you.
89+
If you want to permanently persist this data, pass the CUPS_LPADMIN_PRINTER env variable to setup the printer on startup
90+
91+
## Docker Compose
92+
If you don't want to type out these long **Docker** commands, you could
93+
optionally use [docker-compose](https://docs.docker.com/compose/) to set up your
94+
image. Just download the repo and run it like so:
95+
96+
```yaml
97+
version: '3.8'
98+
services:
99+
cups:
100+
image: rogerrum/cups-airprint:latest
101+
container_name: cups
102+
network_mode: host
103+
restart: unless-stopped
104+
environment:
105+
- CUPS_REMOTE_ADMIN="yes"
106+
- CUPS_REMOTE_ADMIN="yes"
107+
- CUPS_LPADMIN_PRINTER1=lpadmin -p brother -D 'Brother HL2270 printer' -m 'HL2270DW.ppd' -v lpd://<printer-host>/BINARY_P1
108+
- CUPS_LPADMIN_PRINTER1_ENABLE=cupsenable brother
109+
- CUPS_LPADMIN_PRINTER1_ACCEPT=cupsaccept brother
110+
```
111+
112+
## Issues:
113+
https://github.com/rogerrum/cups-airprint/issues
114+
115+
# Credits
116+
This is based on awesome work of others
117+
* https://github.com/quadportnick/docker-cups-airprint
118+
* https://github.com/DrPsychick/docker-cups-airprint
119+
* https://github.com/RagingTiger/cups-airprint
120+
121+
# Contribute
122+
* I am happy for any feedback! Create issues, discussions, ... feel free and involve!
123+
* Send me a PR

0 commit comments

Comments
 (0)