我想在Dockerfile RUN命令中添加一台打印机,所以这是我的Dockerfile
FROM dassh/eline:base
MAINTAINER dassh
# start cups service is necessary to run lpadmin command
RUN service cups start && lpadmin -p VLM2601 -v EleanBackend:/tmp -m
VLM2601_gdi.ppd -E && echo done
构建程序
docker build -t dassh/eline .
Sending build context to Docker daemon 722.9kB
Step 1/3 : FROM dassh/eline:base
---> 712dce8cd557
Step 2/3 : MAINTAINER dassh
---> Running in 2f3f5f80b665
Removing intermediate container 2f3f5f80b665
---> 2b53b81d6ff4
Step 3/3 : RUN service cups start && lpadmin -p VLM2601 -v EleanBackend:/tmp -m VLM2601_gdi.ppd -E && echo done
---> Running in f176fbdf765e
* Starting Common Unix Printing System cupsd
...done.
done
Removing intermediate container f176fbdf765e
---> e229e278b085
Successfully built e229e278b085
Successfully tagged dassh/eline:latest
构建成功,没有任何错误。但是,当我使用此图像启动容器时,我发现没有添加打印机。
dassh@ubuntu:~$ docker run -itd dassh/eline /bin/bash
a8785057e71a598cd391f355848819295fef8e311090f70cbae95ca5360856c2
dassh@ubuntu:~$ docker cp ~/123.pdf a8:/
dassh@ubuntu:~$ docker attach a8
root@a8785057e71a:/pdf_to_prn#
root@a8785057e71a:/pdf_to_prn# service cups start
* Starting Common Unix Printing System cupsd [ OK ]
root@a8785057e71a:/pdf_to_prn# lp -o fit-to-page -o media=A4 -d VLM2601 /123.pdf
lp: The printer or class does not exist.
该命令返回打印机不存在的错误,但是当我手动在容器中执行add printer命令并再次运行lp命令时,一切都很好。
root@a8785057e71a:/pdf_to_prn# lpadmin -p VLM2601 -v EleanBackend:/tmp -m VLM2601_gdi.ppd -E
root@a8785057e71a:/pdf_to_prn# lp -o fit-to-page -o media=A4 -d VLM2601 /123.pdf
request id is VLM2601-1 (1 file(s))
因此,我的添加打印机命令没有问题。那么发生了什么?
答案 0 :(得分:1)
使用lpadmin
创建打印机导致的问题。
/etc/cups/printers.conf
获取打印机。lpadmin
添加打印机将生成或更新文件/etc/cups/printers.conf
。 Dockerfile在生成文件/etc/cups/printers.conf
之前完成此步骤。