从Docker容器内部打印

12

随着 GUI 应用程序被移植到 Docker 上,从 Docker 容器内部打印到 CUPS 的最佳方法是什么?

NB: 我不希望在容器内运行 CUPS,因为这会破坏与 Docker 相关的单个服务范例。

1个回答

12

在研究如何实现这个目标后,自描述性有所提升。

在基于Ubuntu的Docker主机上,将打印机安装在杯子插座中效果良好...(acroread无法填充打印机),然而在Redhat主机上失败了。

...
-v /var/run/cups:/var/run/cups:ro
...

填充cups client.conf似乎是一个更好的解决方案。

cat /tmp/client.conf

#The ServerName directive specifies sets the remote server 
# that is to be used for all client operations. That is, it 
# redirects all client requests to the remote server. The 
# default port number is 631 but can be overridden by adding
# a colon followed by the desired port number to the value.
# The default is to use the local server ("localhost").
ServerName <DOCKER0 BRIDGE IP>

以及Docker启动参数:

...
-v /tmp/client.conf:/etc/cups/client.conf:ro \
...

我还必须确保cups服务器绑定到docker0桥,并允许其他设备访问cups服务器:

...
Listen *:631
...
<Location />
  Order allow,deny
  Allow all
</Location>
...

一旦cups重新启动并将cups client.conf传递到容器中,我就能按预期进行打印。


根据您的Docker启动参数,看起来您在主机上创建了一个名为client.conf的文件,路径为/tmp/client.conf,然后将其挂载到容器内的路径/etc/cups/client.conf(只读)。您是从Docker容器中打印还是从主机打印到Docker容器中? - waspinator
只是浏览了一些文档,似乎使用client.conf已经被弃用。您应该在容器内安装本地CUPS服务器,然后从本地服务器打印到远程CUPS服务器。看起来没有绕过这个问题的方法,以实现“单一服务范式”。无论如何,php+apache容器已经有了先例。https://wiki.archlinux.org/index.php/CUPS#Without_a_local_CUPS_server - waspinator

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接