Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to answer dialog questions when installing under docker?

Is it possible to somehow answer the questions that are presented as dialogs when installing some packages using apt-get?

For instance I'm trying to setup a container containing the mail-stack-delivery package with:

FROM ubuntu

RUN apt-get install -y mail-stack-delivery

However that dockerfile generates dozens of errors when built that are along the lines of:

debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (Can't locate Term/ReadLine.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.14.2 /usr/local/share/perl/5.14.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.14 /usr/share/perl/5.14 /usr/local/lib/site_perl .) at /usr/share/perl5/Debconf/FrontEnd/Readline.pm line 7, <> line 11.)
debconf: falling back to frontend: Teletype
dpkg-preconfigure: unable to re-open stdin: 

From what I understand I just simply can't respond to the dialogs, but is there some way that I can pass a parameter to answer each question in advance? I know that it's just changing some configurations, so I could do it after the fact, but presumably it's better to let the install scripts do it so everything gets set properly.

like image 825
azdle Avatar asked Mar 17 '14 21:03

azdle


People also ask

Do you need Sudo to install Docker?

The installation script requires root or sudo privileges to install and use Docker. If you want to grant non-root users access to Docker, refer to the post-installation steps for Linux. You can also install Docker without root privileges, or configured to run in rootless mode.

What can you run in Docker?

You can run both Linux and Windows programs and executables in Docker containers. The Docker platform runs natively on Linux (on x86-64, ARM and many other CPU architectures) and on Windows (x86-64).

Is it possible to run multiple containers through a single container?

You can connect multiple containers using user-defined networks and shared volumes. The container's main process is responsible for managing all processes that it starts. In some cases, the main process isn't well-designed, and doesn't handle “reaping” (stopping) child processes gracefully when the container exits.

How is Docker implemented?

Docker uses the union file system to create and layer Docker images. This means all images are built on top of a base image, actions are then added to that base image. For example, RUN apt install curl creates a new image.


3 Answers

See the discussion here: https://github.com/docker/docker/issues/4032. In short, setting ENV DEBIAN_FRONTEND noninteractive is not recommended as it persists in the final image, even when running something like docker run -i -t ... bash. Therefore it is recommended either to omit DEBIAN_FRONTEND and live with the warning, or specify it explicitly for each command e.g. RUN DEBIAN_FRONTEND=noninteractive apt-get install -y -q package.

Fortunately, the new ARG directive sets variables that only live during the build so a more elegant solution is now possible that's specified in the DockerFile yet does not persist in the final image: ARG DEBIAN_FRONTEND=noninteractive.

like image 174
Ohad Schneider Avatar answered Oct 28 '22 23:10

Ohad Schneider


You should set DEBIAN_FRONTEND=noninteractive as an envvar. In most cases this will at least make it so the installation doesn't error out.

Also as @Azdle mentioned, using debconf-set-selections will let you set specific items.

like image 21
cpuguy83 Avatar answered Oct 29 '22 00:10

cpuguy83


As usual, a little more searching found the answer.

The answer is debconf-set-selections. Manpage: http://manpages.ubuntu.com/manpages/oneiric/en/man1/debconf-set-selections.1.html

To find the options that can be set use debconf-get-selections on a system that already has the package installed. You'll need to install debconf-utils for the second command.

like image 39
azdle Avatar answered Oct 28 '22 23:10

azdle