我想在 docker compose 容器之间进行打印。有两个容器存在问题:
- cups:cups 守护进程
- php-apache:使用 lp 打印
杯子容器:
本地打印,示例
$ lp -d developer-epson-alm320dn -h cups:631 -n 1 sample.pdf
request id is developer-epson-alm320dn-6 (1 file(s))
cupsd.conf 的头部
LogLevel warn
PageLogFormat
MaxLogSize 0
ErrorPolicy retry-job
ServerName *
# Allow remote access
Port 631
Listen /run/cups/cups.sock
# Share local printers on the local network.
Browsing On
BrowseLocalProtocols dnssd
DefaultAuthType Basic
WebInterface Yes
DefaultEncryption IfRequested
<Location />
# Allow shared printing and remote administration...
Order allow,deny
Allow all
</Location>
# ...
php-apache 容器
$ lp -d developer-epson-alm320dn -h cups:631 -n 1 /tmp/print-KflCQR.pdf
lp: Error - The printer or class does not exist.
$ ping cups
PING cups (172.18.0.2) 56(84) bytes of data.
64 bytes from mssystem-cups.docker_default (172.18.0.2): icmp_seq=1 ttl=64 time=0.082 ms
$ curl cups:631/printers/developer-epson-alm320dn | grep SUMMARY
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0<TABLE SUMMARY="developer-epson-alm320dn">
100 4650 0 4650 0 0 756k 0 --:--:-- --:--:-- --:--:-- 756k
答案1
我解决了这个问题:
#... install cups-client and:
RUN mkdir -p /etc/cups && echo "ServerName cups" > /etc/cups/client.conf
#...
打印命令正常工作后:
$ lp -d developer-epson-alm320dn -n 1 sample.pdf
答案2
出于某种原因,它通过反转参数而对我来说是有效的,而不必创建和/或向 client.conf 添加一行。
所以你问题中的命令可以这样运行,把主机参数放在第一位!
lp -h cups:631 -d developer-epson-alm320dn -n 1 sample.pdf