我正在尝试在Docker上安装apt-utils
,因为当我刚刚执行apt-get update
时,我收到错误:所以我添加了一行来安装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
是什么原因导致了这种情况?我该如何解决?
4条答案
按热度按时间hc8w905p1#
这实际上不是一个错误,忽略它是安全的。我已经构建了大量的容器映像,其中任何一个都没有
apt-utils
,不管这个警告消息,所有的包安装都可以正常进行。无论如何,如果你想安装
apt-utils
,它会给予你这个警告 * 一次 *,然后它会在以后调用apt-get
时消失(正如你在自己的日志中看到的,curl
安装时没有这个消息)。注意如果你安装了
apt-utils
,你会收到其他警告(因为现在安装程序 * 可以 * 运行交互式配置,并且会尝试运行交互式配置,但是会失败)。要取消这些警告,并使软件包具有默认的交互式配置,请像DEBIAN_FRONTEND=noninteractive apt-get install -y pkgs....
这样运行apt-get
bq9c1y662#
在网上搜索之后,我发现了一些值得一提的替代方案,而不是每次都把
DEBIAN_FRONTEND=noninteractive
放在apt-get install -y {your-pkgs}
前面:ARG指令定义了一个变量,用户可以在构建时通过docker build命令使用--build-arg =标志将该变量传递给构建器。(参考:[6])
溶液特性:
ARG
指令docker build --build-arg DEBIAN_FRONTEND=newt
)来更改它示例:
溶液特性:
RUN
,不会影响其他指令。示例:
设置
ENV DEBIAN_FRONTEND noninteractive
也是一种替代方法,但强烈建议不要这样做。另一种方法是在Dockerfile的开头设置,在结尾取消设置。
溶液特性:
ENV
指令将在生成后保持环境变量(不推荐),此外ENV
设置的,所以它将被所有映像继承,并包含从映像构建的内容,从而有效地改变它们的行为。(如[1]中所述)使用这些映像的人在交互式安装软件时会遇到问题,因为安装程序不显示任何对话框。DEBIAN_FRONTEND=newt
(参见[2],因此必须在文件末尾设置。示例:
溶液特性:
RUN
,不会影响其他指令。示例:
k10s72fa3#
请运行
apt-get install apt-utils
,瞧,安装完毕,没有警告。bfhwhh0e4#
这是一个持续存在的问题,没有很好的解决方案......我选择了这个,它不是最佳的,但它起作用了:
说明:
grep -v
反向匹配,以开头的行将消失!证明这是可行的:https://asciinema.org/a/WJCDEYcxCIy6EF7eXw0MAnK3c