version=$(cat ${PWD}/VERSION)
docker build -t registry.gitlab.com/tdmsa/service-printer:$version .
mkdir -p ${PWD}/printdrop
# Grant container access to the host CUPS socket's group
CUPS_GID=$(stat -c %g /run/cups/cups.sock)
docker run --rm \
--name printer-service \
--network=host \
--user $(id -u):$(id -g) \
--group-add ${CUPS_GID} \
-e DISCOVERY_METHODS=cups,mdns \
-e CUPS_SERVER=/run/cups/cups.sock \
-v /run/cups/cups.sock:/run/cups/cups.sock \
-v /etc/cups:/etc/cups:ro \
-v ${PWD}/printdrop:/data/printers \
registry.gitlab.com/tdmsa/service-printer:$versionDrop PDFs into /srv/printdrop/<queue_name>/. Each file is submitted to CUPS and then moved into /srv/printdrop/<queue_name>/archive/.
- If set, it explicitly controls which queues the container manages. Only those listed will get folders and be monitored. Format:
[
{ "name": "QueueA" },
{ "name": "HP_Color_LaserJet_M455_B94849" }
]- If not set, at startup the container will:
- Discover available queues from CUPS,
- Manage those queues,
- Print a ready-to-copy PRINTER_STATIC_JSON suggestion to the logs so you can pin the set of managed queues and restart with it.
This makes it easy to lock down exactly which printers are used.
- BASE_PATH=/data/printers
- ARCHIVE_SUBDIR=archive
- DISCOVERY_METHODS=cups,mdns (comma list: cups, mdns, static)
- FILE_STABLE_SECONDS=2
- PRINT_RETRY_COUNT=3
- PRINT_RETRY_DELAY=5
- INCLUDE_REGEX=
- EXCLUDE_REGEX=
- PRINTER_STATIC_JSON=
- LOG_LEVEL=INFO
- USE_PYCUPS=1
- CREATE_MISSING=1
- CUPS_SERVER=
- Set to
/run/cups/cups.sockto use the mounted host socket. - Or
host:portto target remote CUPS directly.
- Set to
- Managing only CUPS queues by default avoids mDNS-only devices that are not set up as queues (which would fail). You can still keep mdns in discovery to aid future queue setup.
- If you see “printer or class does not exist,” ensure:
- You mounted the socket and added its group to the container (see quick start).
- The queue exists in host CUPS (
lpstat -pon host). - CUPS_SERVER is correct.
- Permission denied on /data/printers: run with
--user $(id -u):$(id -g)or chown/chmod the host directory for write access. - No queues discovered: verify CUPS is running; socket is mounted; container has the socket’s group; and
CUPS_SERVER=/run/cups/cups.sockis set. - Jobs fail for statically listed queues: ensure the queue name exactly matches CUPS (
lpstat -p), and that the container can reach CUPS.