我正在尝试在Docker上安装apt-utils
,因为当我刚做apt-get update
时,出现了错误:debconf: delaying package configuration, since apt-utils is not installed
。因此,我添加了一行来安装apt-utils
(以及curl
):
RUN apt-get update && apt-get install -y apt-utils && apt-get install -y curl
但是,我仍然遇到该错误,使我相信我的命令无效。下面是我尝试构建图像时的输出。
Step 5/12 : RUN apt-get update && apt-get install -y apt-utils && apt-get install -y curl
---> Running in 6e6565ff01bd
Get:1 http://security.debian.org jessie/updates InRelease [94.4 kB]
Ign http://deb.debian.org jessie InRelease
Get:2 http://deb.debian.org jessie-updates InRelease [145 kB]
Get:3 http://deb.debian.org jessie Release.gpg [2420 B]
Get:4 http://deb.debian.org jessie Release [148 kB]
Get:5 http://security.debian.org jessie/updates/main amd64 Packages [624 kB]
Get:6 http://deb.debian.org jessie-updates/main amd64 Packages [23.0 kB]
Get:7 http://deb.debian.org jessie/main amd64 Packages [9098 kB]
Fetched 10.1 MB in 6s (1541 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
The following extra packages will be installed:
libapt-inst1.5
The following NEW packages will be installed:
apt-utils libapt-inst1.5
0 upgraded, 2 newly installed, 0 to remove and 24 not upgraded.
Need to get 537 kB of archives.
After this operation, 1333 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian/ jessie/main libapt-inst1.5 amd64 1.0.9.8.4 [169 kB]
Get:2 http://deb.debian.org/debian/ jessie/main apt-utils amd64 1.0.9.8.4 [368 kB]
debconf: delaying package configuration, since apt-utils is not installed
Fetched 537 kB in 0s (557 kB/s)
Selecting previously unselected package libapt-inst1.5:amd64.
(Reading database ... 21676 files and directories currently installed.)
Preparing to unpack .../libapt-inst1.5_1.0.9.8.4_amd64.deb ...
Unpacking libapt-inst1.5:amd64 (1.0.9.8.4) ...
Selecting previously unselected package apt-utils.
Preparing to unpack .../apt-utils_1.0.9.8.4_amd64.deb ...
Unpacking apt-utils (1.0.9.8.4) ...
Setting up libapt-inst1.5:amd64 (1.0.9.8.4) ...
Setting up apt-utils (1.0.9.8.4) ...
Processing triggers for libc-bin (2.19-18+deb8u10) ...
Reading package lists...
Building dependency tree...
Reading state information...
curl is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 24 not upgraded.
Removing intermediate container 6e6565ff01bd
---> f65e29c6a6b9
Step 6/12 : RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash
---> Running in f5764ba56103
Detected operating system as debian/8.
Checking for curl...
Detected curl...
Checking for gpg...
Detected gpg...
Running apt-get update... done.
Installing debian-archive-keyring which is needed for installing
apt-transport-https on many Debian systems.
Installing apt-transport-https... done.
Installing /etc/apt/sources.list.d/github_git-lfs.list...done.
Importing packagecloud gpg key... done.
Running apt-get update... done.
The repository is setup! You can now install packages.
Removing intermediate container f5764ba56103
---> a4e64687ab73
是什么原因造成的,我该如何解决?谢谢!
答案 0 :(得分:30)
这实际上不是错误,可以忽略它。我已经构建了许多容器映像,而它们中的任何一个都没有安装apt-utils,并且不管此警告消息如何,所有软件包安装都可以正常进行。
无论如何,如果您想拥有apt-utils,请安装它。它将在一次时发出警告,然后在以后调用apt-get时将消失(如在您自己的日志中看到的,Function Regex-Remove
{
Param
(
[Parameter(Mandatory=$true)]
$local_regex,
[Parameter(Mandatory=$true)]
$hosts
)
# Loop through each regex and select only non-matching items
foreach($regex in $local_regex)
{
# Multi line, case insensitive
$regex = "(?im)$regex"
# Select hosts that do not match regex
$hosts = $hosts -notmatch $regex
}
return $hosts
}
已安装而没有该消息)。>
注意,如果您安装apt-utils,则会收到其他警告(因为现在安装程序可以运行交互式配置,并且会尝试并失败)。要禁止显示这些包,并使用默认配置进行交互式配置,请运行curl
答案 1 :(得分:6)
通过Internet搜索之后,我发现了一些值得一提的替代方法,而不是每次都将DEBIAN_FRONTEND=noninteractive
放在apt-get install -y {your-pkgs}
前面:
替代方法1:ARG DEBIAN_FRONTEND =非交互式
ARG指令定义了一个用户可以在其处传递的变量 使用docker build命令构建到构建器的时间 --build-arg =标志。 (参考:[6])
解决方案特征:
ARG
指令仅在构建期间设置docker build --build-arg DEBIAN_FRONTEND=newt
示例:
ARG DEBIAN_FRONTEND=noninteractive
...
RUN apt-get -yq install {your-pkgs}
替代2:即时
这是Leo K的解决方案。
解决方案特征:
RUN
,不会影响其他指令。示例:
RUN DEBIAN_FRONTEND=noninteractive apt-get -yq install {your-pkgs}
替代3:ENV DEBIAN_FRONTEND =非交互式
设置ENV DEBIAN_FRONTEND noninteractive
也可以作为一种选择,但是强烈建议不要这样做。
另一种方法是在乞讨处设置,然后在Dockerfile的末尾取消设置。
解决方案特征:
ENV
指令将在构建后保留环境变量(不推荐),此外ENV
,因此它将被所有图像继承,并包含从该图像构建的容器,从而有效地更改其行为。 (如[{1中所述),在交互式安装软件时,使用这些映像的人会遇到问题,因为安装程序不会显示任何对话框。DEBIAN_FRONTEND=newt
(请参见[2],因此必须在文件末尾进行设置。示例:
# Set for all apt-get install, must be at the very beginning of the Dockerfile.
ENV DEBIAN_FRONTEND noninteractive
...
# Non-interactive modes get set back.
ENV DEBIAN_FRONTEND newt
替代4:运行导出DEBIAN_FRONTEND =非交互式
解决方案特征:
RUN
,不会影响其他指令。示例:
# Set the frontend and then install your package
RUN export DEBIAN_FRONTEND=noninteractive && \
...
apt-get -yq install {your-pkgs} && \
...
更多阅读内容(参考)
答案 2 :(得分:1)
这是一个持续存在的问题,没有很好的解决方案......我选择了这个,它不是最佳的,但它有效:
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y apt-utils 2>&1 | \
grep -v "^debconf: delaying package configuration, since apt-utils.*"
说明:
grep -v
反向匹配,以该开头的行将消失!