Dockerized CUPS/AirPrint
No further updates to the repository will be made at this time. Please see the forks for any possible solutions to your specific use case and/or the
author-suggested repo at: https://github.com/chuckcharlie/cups-avahi-airprint.
Modified copy of source code at:
https://github.com/quadportnick/docker-cups-airprint
This Ubuntu-based Docker image runs a CUPS instance that is meant as an AirPrint
relay for printers that are already on the network but not AirPrint capable.
The local Avahi will be utilized for advertising the printers on the network.
The below commands reference a
Docker Manifest List
at ghcr.io/ragingtiger/cups-airprint:master
built using Docker’s
BuildKit.
Simply running commands using this image will pull
the matching image architecture (e.g. amd64
, arm32v7
, or arm64
) based on
the hosts architecture. Hence, if you are on a Raspberry Pi the below
commands will work the same as if you were on a traditional amd64
desktop/laptop computer. Note: Because the image requires ubuntu
as its base
image, there is currently no arm32v6
architecture available. This means if your
target hardware is a Raspberry Pi Zero or similar arm 6
architecture, this
image will not run.
This section will give an overview of the essential options/arguments to pass
to docker to successfully run containers from the ghcr.io/ragingtiger/cups-airprint:master
docker image.
To simply do a quick and dirty run of the cups/airprint container:
docker run \
-d \
--name=cups \
--net=host \
-v /var/run/dbus:/var/run/dbus \
--device /dev/bus \
--device /dev/usb \
-e CUPSADMIN="admin" \
-e CUPSPASSWORD="password" \
ghcr.io/ragingtiger/cups-airprint:master
To stop the container simply run:
docker stop cups
To remove the conainer simply run:
docker rm cups
WARNING: Be aware that deleting the container (i.e. cups
in the example)
will permanently delete the data that docker volume
is storing for you.
If you want to permanently persist this data, see the docker create
example
below. Continue reading the Notes section for more details about
Docker volumes
Dockerfile
explicitly sets volumes at /config
and/services
(seedocker container
will be/var/lib/docker/volumes
(see for referenceCreating a container is often more desirable than directly running it:
docker create \
--name=cups \
--restart=always \
--net=host \
-v /var/run/dbus:/var/run/dbus \
-v ~/airprint_data/config:/config \
-v ~/airprint_data/services:/services \
--device /dev/bus \
--device /dev/usb \
-e CUPSADMIN="admin" \
-e CUPSPASSWORD="password" \
ghcr.io/ragingtiger/cups-airprint:master
Follow this with docker start
and your cups/airprint printer is running:
docker start cups
To stop the container simply run:
docker stop cups
To remove the conainer simply run:
docker rm cups
Dockerfile
explicitly declares two volumes at /config
and /services
/config
and /services
. Why? Because/config
and /services
~/airprint_data/config
and ~/airprint_data/services
--name
: gives the container a name making it easier to work with/on (e.g.cups
)--restart
: restart policy for how to handle restarts (e.g. always
restart)--net
: network to join (e.g. the host
network)-v ~/airprint_data/config:/config
: where the persistent printer configs-v ~/airprint_data/services:/services
: where the Avahi service files will-e CUPSADMIN
: the CUPS admin user you want created-e CUPSPASSWORD
: the password for the CUPS admin user--device /dev/bus
: device mounted for interacting with USB printers--device /dev/usb
: device mounted for interacting with USB printersIf you don’t want to type out these long Docker commands, you could
optionally use docker-compose to set up your
image. Just download the repo and run it like so:
git clone https://github.com/RagingTiger/docker-cups-airprint
cd docker-cups-airprint
docker-compose up
NOTE: This compose file is made with USB
printers in mind and like the above
commands has device
mounts for USB
printers. If you don’t have a USB
printer you may want to comment these out. Also the config/services
data will
be saved to the users $HOME
directory. Again you may want to edit this to
your own liking.
If you would like to build the image yourself (locally), pull down the repo and
run the docker build
command as follows:
git clone https://github.com/RagingTiger/docker-cups-airprint
cd docker-cups-airprint
docker build -t tigerj/cups-airprint .
Follow this with a docker run or docker create to deploy
your container and your cups-airprint server is ready to be configured and
used.
CUPS will be configurable at http://localhost:631 using the
CUPSADMIN/CUPSPASSWORD when you do something administrative.
If the /services
volume isn’t mapping to /etc/avahi/services
then you will
have to manually copy the .service files to that path at the command line.
printers.conf
immediately when making changes evenHere we are going to discuss the most common problems that users have when
trying to setup and configure their printer to work with the
tigerj/cups-airprint image.
As you might imagine this is the most common problem users have when setting
up their printers. While the tigerj/cups-airprint image possesses
multiple printer drivers, it most likely does not have every driver for
every printer. This issue can be resolved as follows:
Sometimes the right printer driver is installed in the tigerj/cups-airprint
Docker image, but the version is not current. This issue may require one of
two choices to resolve:
Download the docker-cups-airprint git repo and build a fresh image
Download driver DIRECTLY from the manufacturer and add it to the image