如何编写可以传递yes的Dockerfile来提示许可协议?
docker build -t "{user}/{tags}" .
然后构建失败。docker logs {container id}
,显示如下信息:
Preparing to unpack .../ttf-mscorefonts-installer_3.4+nmu1ubuntu2_all.deb ...
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
Configuring ttf-mscorefonts-installer
TrueType core fonts for the Web EULA END-USER LICENSE AGREEMENT FOR
MICROSOFT SOFTWARE
...
Do you accept the EULA license terms? [yes/no]
跟随在这里issue: [16.04] debconf: delaying package configuration, since apt-utils is not installed的讨论。
我在Dockerfile中添加了这三行代码:
ENV DEBIAN_FRONTEND noninteractive
ENV DEBIAN_FRONTEND teletype
RUN apt-get update -y && apt-get install -y --no-install-recommends apt-utils \
最后成功构建了docker镜像!
您可以基于此尝试此解决方案:https://unix.stackexchange.com/a/106553
$ apt-get install -y PACKAGE
debconf
设置 $ debconf-get-selections | grep PACKAGE
PACKAGE PACKAGE/key string y
ENV DEBIAN_FRONTEND=teletype
RUN echo PACKAGE PACKAGE/key type string y | debconf-set-selections && \
apt-get install -y PACKAGE
您可能需要为debconf-utils
安装debconf-set|get-selections
。
您可以在Dockerfile中的行末写一个-y
。
例:
RUN apt-get update
RUN apt-get install netcat -y