Docker commands require keyboard interaction Docker commands require keyboard interaction docker docker

Docker commands require keyboard interaction


The typical template to install apt packages in a docker container looks like:

RUN apt-get update \ && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \    eject \    vim \    ruby \    abcde \ && apt-get clean \ && rm -rf /var/lib/apt/lists/*

Running it with the "noninteractive" value removes any prompts. You don't want to set that as an ENV since that would also impact any interactive commands you run inside the container.

You also want to cleanup the package database when finished to reduce the layer size and avoid reusing a stale cached package database in a later step.

The no-install-recommends option will reduce the number of packages installed by only installing the required dependencies, not the additional recommended packages. This cuts the size of the root filesystem down by half for me.


If you need to pass a non-default configuration to a package, then use debconf. First run you install somewhere interactively and enter the options you want to save. Install debconf-utils. Then run:

debconf-get-selections | grep "${package_name}"

to view all the options you configured for that package. You can then pipe these options to debconf-set-selections in your container before running your install, e.g.:

RUN echo "postfix postfix/main_mailer_type        select  No configuration" \  | debconf-set-selections \ && apt-get update \ && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ ....

or save your selections to a file that you copy in:

COPY debconf-selections /RUN debconf-set-selections </debconf-selections \ && apt-get update \ && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ ....