我想在Dockerfile运行命令中添加一个打印机,所以这是我的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打印机命令并再次运行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))因此,我的“添加打印机”命令没有问题。那么到底发生了什么?
发布于 2018-03-27 10:40:33
使用lpadmin创建打印机引起的问题。
/etc/cups/printers.conf获取打印机。lpadmin添加打印机将生成或更新文件/etc/cups/printers.conf。Dockerfile在生成文件/etc/cups/printers.conf之前完成此步骤。
https://stackoverflow.com/questions/49503382
复制相似问题