随着大量 GUI 应用程序被移植到 docker,从 docker 容器内部打印到杯子的最佳方式是什么?

注意:我不希望从容器内部运行 cups,因为这打破了与 docker 相关的单一服务范式。

最佳答案

关于如何实现这一目标的调查工作后的自我记录。

在基于 Ubuntu 的 docker 主机上安装在 cups socket 中效果很好……ish(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 服务器绑定(bind)到 docker0 网桥并允许其他设备访问 cups 服务器:
...
Listen *:631
...
<Location />
  Order allow,deny
  Allow all
</Location>
...

一旦cups重新启动并且cups client.conf 传递到容器中,我就可以按预期打印。

关于docker - 从 docker 容器内打印,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/31030609/

10-15 01:28
查看更多