Various package and software management applications require manual input for execution confirmation by default. This confirmation is usually required when installing, updating, or removing programs and packages. General consent can be given to execute the command without manual input.

Why is this an issue?

Suppose a package manager invocation is part of a script that is executed automatically, and non-interactive mode is not enabled. Then, execution is aborted because there is no confirming manual input. As a result, instructions, such as installation or update of packages, cannot be performed in an automated way. This applies, among others, to the package manager used in Debian-based systems, Advanced Package Tool (APT).

How can I fix it?

Code examples

Noncompliant code example

RUN apt-get install ca-certificates
RUN aptitude install ca-certificates
RUN apt install ca-certificates

Here each line represents a package installation command command for the most popular package managers. Each of them is trying to perform an installation in interactive mode, it will wait for prompt that will never come, so it will result in aborted execution.

Compliant solution

RUN apt-get -y install ca-certificates
RUN aptitude -y install ca-certificates
RUN apt -y install ca-certificates

Here in each line we added the option -y, it will assume yes to all prompts and continue execution.

How does this work?

If the -y flag is set, no manual input is expected, and the package manager can run non-interactively. For apt and apt-get, the long versions --yes and --assume-yes also exist. For aptitude, the long version --assume-yes exists.

Resources

Documentation