代码之家  ›  专栏  ›  技术社区  ›  peachykeen

Docker在安装apt-utils时遇到问题

  •  28
  • peachykeen  · 技术社区  · 6 年前

    我正在尝试安装 apt-utils 因为当我刚开始 apt-get update ,我得到了错误: debconf: delaying package configuration, since apt-utils is not installed 是的。所以我加了一条线来安装 实用程序 (连同 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
    

    是什么引起的?我该怎么解决?谢谢您!

    2 回复  |  直到 6 年前
        1
  •  48
  •   Leo K    6 年前

    这实际上不是一个错误,忽略它是安全的。我已经构建了大量的容器映像,但其中任何一个都没有apt-util,而且不管这个警告消息如何,所有的包安装都会正常进行和工作。

    无论如何,如果你想有适当的实用程序-安装它。它会给你这个警告 一旦 然后它将消失以供将来调用apt-get(如您在自己的日志中所见, curl 安装时没有显示该消息)。

    注意,如果安装APT UTLS,您将得到其他警告(因为现在安装程序) 可以 运行交互式配置,并将尝试该操作并失败)。要抑制这些并使包具有默认的交互式配置,请运行apt-get如下 DEBIAN_FRONTEND=noninteractive apt-get install -y pkgs....

        2
  •  9
  •   KeyMaker00    5 年前

    在网上搜索之后,我发现了一些值得选择的替代方案,而不是每次进行。 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 也会是一个替代方案,但这是非常不鼓励的。

    另一种方法是在乞讨时设置,并在待审文件的末尾取消设置。

    溶液特性:

    • 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:运行export debian_frontend=非交互

    溶液特性:

    • 备选方案2
    • 通过分离,内聚性受到了影响:为什么会导出这个变量以及它属于什么(apt-get)。
    • 范围是 跑步 不会影响其他指令。

    例子:

    # Set the frontend and then install your package
    RUN export DEBIAN_FRONTEND=noninteractive && \
        ...
        apt-get -yq install {your-pkgs} && \
        ...
    

    更多阅读(参考)