This Docker image provides a Flask web application that allows users to upload files and print them using a network printer via CUPS (Common Unix Printing System). The printer is configured via the IPP protocol (Internet Printing Protocol).
- File Upload: Supports
pdf,txt,jpg,jpeg, andpngformats. - Network Printing: Print files to a network printer using IPP.
- Environment Variable Support: Customize printer name and IP address via environment variables.
- CUPS Integration: Manages print jobs through CUPS within the Docker container.
This repository is now a standard Python package using a pyproject.toml and src layout.
Install locally:
pip install ./pythonRun the web app:
web-printList printers (or print a file) from CLI:
web-print-printers
web-print-printers --print-file /path/to/file.pdf --printer "Printer_Name"You can pull the image from Docker Hub using the following command:
docker pull <your-dockerhub-username>/cups-flask-printer:latestRun the container with default printer configuration:
docker run -d -p 5000:5000 <your-dockerhub-username>/cups-flask-printerThis command will:
- Launch the Flask web application on port
5000. - Automatically configure a network printer with the default IPP protocol at
ipp://10.25.0.218/ipp/print.
Once the container is running, open a web browser and navigate to:
http://localhost:5000
You can upload files through the web interface and print them to the configured network printer.
If you want to override the default printer configuration (name or IP address), you can pass environment variables to the container when starting it:
docker run -d -p 5000:5000 \
-e PRINTER_NAME="My_Printer" \
-e PRINTER_IP="192.168.1.100" \
<your-dockerhub-username>/cups-flask-printerIn this example:
- PRINTER_NAME: Specifies the printer name.
- PRINTER_IP: Specifies the IP address of the network printer.
The printer is automatically added to CUPS inside the container using the lpadmin command during container startup:
lpadmin -p $PRINTER_NAME -E -v ipp://$PRINTER_IP/ipp/print -m everywhereTo verify that the printer has been configured inside the container, you can use the following command:
docker exec -it <container-id> lpstat -pThis will list the available printers in the container.
- Upload a file (e.g., PDF) through the web interface.
- The file will be printed using the specified network printer.
- Ensure Printer is Reachable: Verify that the printer is accessible at the specified IP address (
10.25.0.218by default). - Check Container Logs: View the logs inside the container for any errors:
docker logs <container-id>
- Check CUPS Status: Use the following command to verify the status of CUPS inside the container:
docker exec -it <container-id> lpstat -r
This project is licensed under the MIT License.