在docker下安装时可以回答对话框问题吗? [英] Is it possible to answer dialog questions when installing under docker?

查看:117
本文介绍了在docker下安装时可以回答对话框问题吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用apt-get安装某些软件包时,是否可以以某种方式回答作为对话框出现的问题?

Is it possible to somehow answer the questions that are presented as dialogs when installing some packages using apt-get?

例如,我正在尝试使用以下方法设置包含mail-stack-delivery包的容器:

For instance I'm trying to setup a container containing the mail-stack-delivery package with:

FROM ubuntu

RUN apt-get install -y mail-stack-delivery

但是,该dockerfile生成时会产生以下数十种错误:

However that dockerfile generates dozens of errors when built that are along the lines of:

debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (Can't locate Term/ReadLine.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.14.2 /usr/local/share/perl/5.14.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.14 /usr/share/perl/5.14 /usr/local/lib/site_perl .) at /usr/share/perl5/Debconf/FrontEnd/Readline.pm line 7, <> line 11.)
debconf: falling back to frontend: Teletype
dpkg-preconfigure: unable to re-open stdin: 

据我了解,我只是无法响应对话框,但是我可以通过某种方式提前传递参数来回答每个问题吗?我知道它只是在更改某些配置,因此我可以在事后这样做,但是大概最好让安装脚本来执行此操作,以便正确设置所有内容.

From what I understand I just simply can't respond to the dialogs, but is there some way that I can pass a parameter to answer each question in advance? I know that it's just changing some configurations, so I could do it after the fact, but presumably it's better to let the install scripts do it so everything gets set properly.

推荐答案

在此处查看讨论: https ://github.com/docker/docker/issues/4032 .简而言之,不建议设置ENV DEBIAN_FRONTEND noninteractive,因为即使在运行docker run -i -t ... bash之类的命令时,它也会保留在最终图像中.因此,建议要么省略DEBIAN_FRONTEND并保留警告,要么为每个命令明确指定它,例如RUN DEBIAN_FRONTEND=noninteractive apt-get install -y -q package.

See the discussion here: https://github.com/docker/docker/issues/4032. In short, setting ENV DEBIAN_FRONTEND noninteractive is not recommended as it persists in the final image, even when running something like docker run -i -t ... bash. Therefore it is recommended either to omit DEBIAN_FRONTEND and live with the warning, or specify it explicitly for each command e.g. RUN DEBIAN_FRONTEND=noninteractive apt-get install -y -q package.

幸运的是,新的ARG指令设置了仅在构建期间有效的变量,因此现在可以在DockerFile中指定更优雅的解决方案,但该解决方案不会保留在最终映像中: ARG DEBIAN_FRONTEND=noninteractive .

Fortunately, the new ARG directive sets variables that only live during the build so a more elegant solution is now possible that's specified in the DockerFile yet does not persist in the final image: ARG DEBIAN_FRONTEND=noninteractive.

这篇关于在docker下安装时可以回答对话框问题吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆