我正在基于 httpd 创建一个 Docker 映像。
我正在其中安装 CUPS软件,并尝试在其中添加打印机。
使用 RUN 命令-RUN ["apt", "install", "-y", "cups"]
在Docker映像中安装CUPS之后,在下一步中,我尝试重新启动杯子服务,然后使用lpadmin命令添加打印机。
service cups start
lpadmin -p printer_name -E -v url -m everywhere
但是只有当我将这些服务启动并通过在它们之间使用&&符号将打印机命令添加到单个RUN命令中时,它才起作用:
RUN ["service cups start", "&&", "lpadmin -p printer_name -E -v url -m everywhere"]
如果我将它们分开放置,如下所示:
RUN ["service cups start"]
RUN ["lpadmin -p printer_name -E -v url -m everywhere"]
它给了我以下错误:
lpadmin: Unable to connect to server: Bad file descriptor
这是我的Dockerfile内容:
USER root
RUN ["apt", "update"]
RUN ["apt", "install", "-y", "cups"]
RUN ["systemctl", "enable", "cups"]
RUN ["service", "cups", "start", "&&", "./printerslist.sh"]
RUN ["chmod", "-R", "-f", "777", "/var/run"]
ENTRYPOINT ["service", "cups", "restart"]