大网数据广告活动
服务器运维问答

When building from Dockerfile, Debian/Ubuntu package install debconf Noninteractive install not allowed

· 52CE 我爱测

I've set the following environment so that no question/dialog is asked during apt-get install: ENV DEBIAN_FRONTEND noninteractive # export DEBIAN_FRONTEND="noninteractive" Which is equivalent to: export DEBIAN_FRONTEND="nonintera…

问题原文

原帖链接 · Phil L. · CC BY-SA 4.0

I've set the following environment so that no question/dialog is asked during apt-get install:

ENV DEBIAN_FRONTEND noninteractive    # export DEBIAN_FRONTEND="noninteractive"

Which is equivalent to:

export DEBIAN_FRONTEND="noninteractive"

Yet, when building an image from a Dockerfile, at the end of one specific Debian/Ubuntu package install (using apt-get install), package configuration debconf says:

debconf: unable to initialize frontend: Noninteractive    # export DEBIAN_FRONTEND="noninteractive"
debconf: (Bareword "Debconf::FrontEnd::Noninteractive" not allowed while "strict subs" in use at (eval 35) line 3, <> line 1.)
debconf: falling back to frontend: Noninteractive
Subroutine BEGIN redefined at (eval 36) line 2, <> line 1.

社区高分解答

原帖链接 · k0pernikus · CC BY-SA 4.0

It should be actively discouraged to set the DEBIAN_FRONTEND to noninteractive via ENV. The reason is that the environment variable persists after the build, e.g. when you run docker exec -it ... bash. The setting would not make sense here.

There are two other possible ways:

  1. Set it via ARG as this only is available during build:

     ARG DEBIAN_FRONTEND=noninteractive
     RUN apt-get -qq -y install {your-package}
    
  2. Set it on-the-fly when required.

     RUN apt-get update && \
         DEBIAN_FRONTEND=noninteractive apt-get -qq -y install {your-package}
    

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2014-08-08)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。