9

How to write the Dockerfile that can pass yes to prompting license agreement?

  1. under Dockerfile directory, docker build -t "{user}/{tags}" . then build failed.
  2. docker logs {container id}, show message as below:

    Preparing to unpack .../ttf-mscorefonts-installer_3.4+nmu1ubuntu2_all.deb ...
    debconf: unable to initialize frontend: Dialog
    debconf: (TERM is not set, so the dialog frontend is not usable.)
    debconf: falling back to frontend: Readline
    Configuring ttf-mscorefonts-installer
    
    TrueType core fonts for the Web EULA END-USER LICENSE AGREEMENT FOR 
    MICROSOFT SOFTWARE
    ...
    Do you accept the EULA license terms? [yes/no]
    
stackoverYC
  • 490
  • 2
  • 4
  • 13

6 Answers6

11

For me, the ACCEPT_EULA=y before the install did the job, like

RUN apt-get update && ACCEPT_EULA=Y apt-get install PACKAGE -y
vs97
  • 5,765
  • 3
  • 28
  • 41
8

Follow by discuession here issue: [16.04] debconf: delaying package configuration, since apt-utils is not installed.

I added these three lines of codes in Dockerfile:

ENV DEBIAN_FRONTEND noninteractive
ENV DEBIAN_FRONTEND teletype

RUN apt-get update -y && apt-get install -y --no-install-recommends apt-utils \

Finally I can build the docker image !

stackoverYC
  • 490
  • 2
  • 4
  • 13
2

You can try this solution based on this: https://unix.stackexchange.com/a/106553

  1. Install the package manually first (i.e. on an existing container, on a local machine)
    $ apt-get install -y PACKAGE
    
  2. Once it's installed, get the debconf setting for the license
    $ debconf-get-selections | grep PACKAGE
    PACKAGE    PACKAGE/license    string    y
    
  3. Now to build the Docker image with a Dockerfile:
    ARG DEBIAN_FRONTEND=noninteractive
    RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections && \
        echo PACKAGE PACKAGE/license string y | debconf-set-selections && \
        apt-get install -y PACKAGE
    

You might need to install debconf-utils for debconf-set|get-selections.

Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
2

I was able to agree to a license during the build process of a Dockerfile by piping the installation that required the confirmation with the yes command, which spams y or yes to any confirmation prompt (see here). Before, my build process was still getting stuck on the [yes/no] prompt like you describe. Note, that the steps described in this answer are still required. Without them, the yes command doesn't seem to be enough, as the build process still gets stuck on the [yes/no] prompt.

This is what I have in my dockerfile:

ENV DEBIAN_FRONTEND noninteractive
ENV DEBIAN_FRONTEND teletype
RUN yes | apt-get install <package>

With that, I can automatically accept prompts in the terminal: enter image description here

It actually also works for these "debian confirmation dialogues" (don't know the correct term): enter image description here

Maybe that helps :)

frietz58
  • 41
  • 4
0

Something that worked for me was to use expect.

Installed dependency: apt-get install -y expect

Then execute:

/usr/bin/expect -<< EOS
    spawn /opt/splunkforwarder/bin/splunk start \
        --accept-license --answer-yes --no-prompt
    expect eof
EOS

without expect the splunk start just got stuck when building the docker image.

-6

You can write a -y at the end of your line in the Dockerfile.

Example:

RUN         apt-get update
RUN         apt-get install netcat -y
Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
Kilian
  • 1,753
  • 13
  • 21
  • I already add `-y` to every `apt-get` commands. :( It's the same problem with this [issue](https://github.com/phusion/baseimage-docker/issues/319), didn't success yet. – stackoverYC Mar 02 '18 at 04:01