This Docker container automatically generates a color test PDF and prints it to a networked Canon printer using CUPS and cron.
It's designed to keep inkjet printers like the Canon Maxify GX7050 healthy by preventing ink from drying out or air from entering the tubes.
Additionally, it provides a Flask-based webserver to monitor print job execution, view logs, and see cron job schedules via a friendly interface.
Ideal for inkjet printer owners who don't print frequently but want to avoid clogged nozzles.
- π¨ Generates a PDF with Cyan, Magenta, Yellow, and Black blocks (or blank for testing)
- π¨οΈ Prints via IPP using CUPS
- π Scheduled weekly print every Friday at 11:00 AM CEST via cron
- π Web interface for:
- Viewing the latest print execution status and logs
- Browsing print job history
- Displaying human-readable cron job schedules
- Showing container version and current year in footer
- βοΈ Configurable via environment variables
- π§ Sends email and/or Telegram notifications on print success/failure
- π§ͺ Supports dry-run with blank PDF generation
You can pull the image directly from Docker Hub:
docker pull geertmeersman/print-color-test
Or visit the repository directly:
π https://hub.docker.com/r/geertmeersman/print-color-test
Variable | Description |
---|---|
PRINTER_URI |
IPP URI of the printer (e.g. ipp://10.0.0.24:631/ipp/print ) |
PRINTER_NAME |
Optional printer name (used in notifications only, not in lp ) |
PRINTER_IP |
IP address of the printer (used by the web interface for status) |
WEB_PORT |
Port for the Flask web interface (default: 80) |
SMTP_SERVER |
SMTP server (e.g. smtp.gmail.com ) to enable email notifications |
SMTP_PORT |
SMTP server port (default: 587 ) |
SMTP_USER |
SMTP username (usually same as EMAIL_FROM ) |
SMTP_PWD |
SMTP password or app password |
EMAIL_FROM |
Sender email address |
EMAIL_TO |
Recipient email address |
TELEGRAM_BOT_ID |
Telegram bot token (e.g. 123456:ABCDEF ) |
TELEGRAM_CHAT_ID |
Telegram chat ID to receive messages |
π The actual printer used by
lp
is hardcoded asMyPrinter
.
docker build -t print-color-test .
docker run --rm \
-e PRINTER_URI=ipp://10.0.0.24:631/ipp/print \
-e PRINTER_NAME="Canon GX7050" \
-e PRINTER_IP=10.0.0.24 \
print-color-test
version: '3.8'
services:
print-color-test:
image: geertmeersman/print-color-test
container_name: print-color-test
environment:
PRINTER_URI: ipp://10.0.0.24:631/ipp/print
PRINTER_NAME: Canon GX7050
PRINTER_IP: 10.0.0.24
WEB_PORT: 80
EMAIL_FROM: printer@example.com
EMAIL_TO: you@example.com
SMTP_SERVER: smtp.gmail.com
SMTP_PORT: 587
SMTP_USER: printer@example.com
SMTP_PWD: your_app_password
TELEGRAM_BOT_ID: 123456:ABCDEF
TELEGRAM_CHAT_ID: -12345678
ports:
- "631:631" # Optional: expose CUPS web interface
- "80:80" # Flask web interface (change if you set WEB_PORT differently)
tty: true
docker-compose up -d
- The Flask webserver runs on 0.0.0.0 binding to the port set by WEB_PORT (default: 80).
- Use the web UI to:
- Check current print job status and logs
- Browse print history
- View the cron job schedule in a human-readable format
- See container version and current year in the footer
The webserver is automatically started inside the container by:
exec gunicorn --chdir /home/flask --bind 0.0.0.0:$WEB_PORT --worker-class eventlet --timeout 120 web_interface:app
Screenshot
Prints every Friday at 11:00 AM CEST via cron.
Cron job:
0 11 * * 5 /usr/local/bin/weekly_print.sh >> /var/log/cron.log 2>&1
Script: weekly_print.sh
#!/bin/bash
echo "[INFO] Running weekly print job at $(date)"
# Generate PDF
python3 /home/generate_pdf.py
# Print
if lp -d MyPrinter /home/color_test_page_dated.pdf; then
echo "[INFO] Print job succeeded. Sending notifications..."
python3 /home/send_notification.py "SUCCESS" "Color test page printed successfully at $(date)."
else
echo "[ERROR] Print job failed. Sending notifications..."
python3 /home/send_notification.py "FAILURE" "Color test page FAILED to print at $(date)."
fi
docker exec -it <container_id> bash
Inside the container:
lpstat -p # Printer status
lpstat -o # Print queue
cancel -a # Cancel all jobs
/usr/local/bin/weekly_print.sh # Launch the color test print job and push notifications if the environment variables are set
lp -d MyPrinter /home/color_test_page_dated.pdf # Manual print test
/home/test_empty.sh # Generate an empty PDF, send it to the printer and push notifications if the environment variables are set
Questions, feedback, or want to chat?
π¨ Discord: discordapp.com/users/geertmeersman
MIT
To receive print job notifications via Telegram, youβll need:
- A Telegram Bot Token (
TELEGRAM_BOT_ID
) - Your Chat ID (
TELEGRAM_CHAT_ID
)
- Open Telegram and search for
@BotFather
- Start a chat and send:
/newbot
- Follow the prompts to name your bot
- Youβll get a token that looks like:
This is your
123456789:ABCDefGhIjKlMnOpQRStuvWxYz
TELEGRAM_BOT_ID
- Start a chat with your new bot (just send it any message)
- Open your browser and visit:
For example:
https://api.telegram.org/bot<YOUR_BOT_ID>/getUpdates
https://api.telegram.org/bot123456789:ABCDefGhIjKlMnOpQRStuvWxYz/getUpdates
- Look for the
chat.id
in the response:"chat": { "id": 123456789, ... }
- If youβre using a group, add the bot to the group and look for a negative number like
-987654321
- If youβre using a group, add the bot to the group and look for a negative number like
This is your TELEGRAM_CHAT_ID
TELEGRAM_BOT_ID=123456789:ABCDefGhIjKlMnOpQRStuvWxYz
TELEGRAM_CHAT_ID=123456789