How to accept license agreement during docker buil

2019-07-23 15:16发布

问题:

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]
    

回答1:

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 Successfully built the docker image !



回答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
  1. Once it's installed, get the debconf setting for the license
    $ debconf-get-selections | grep PACKAGE
    PACKAGE    PACKAGE/license    string    y
  1. Now to build the image with a the 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.



回答3:

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