Monthly Archives: June 2015

Supress messages – Docker- Debian package install using apt-get

Working with docker, we ran into an issue trying to install nginx with passenger.

nginx tries to over-write a pre-existing file with a default config and asks via the dpkg for user input to confirm, the result caused docker to fail.

Suppress confirmatory prompts from APT

APT will prompt for confirmation if it needs to install or remove packages beyond those explicitly requested, or if it is unable to verify the authenticity of a package. You can suppress this behaviour by setting the APT::Get::Assume-Yes option to true. This can be done temporarily using the -y command line option of apt or aptitude.

Suppress prompts from dpkg to resolve conffile differences

Installing one package may cause other packages to be upgraded. If this involves upgrading a configuration file that has also been changed locally then dpkg normally asks the user what to do: keep the existing copy, overwrite it with the new copy, or resolve the conflict manually.

The safest course of action is to keep the existing configuration file if it has local changes, but otherwise allow the upgrade. This can be achieved using a combination of two dpkg options:

–force-confdef (upgrade the configuration file if there are no local changes), and
–force-confold (otherwise, preserve the existing configuration file).

Suppress requests for information during package configuration

export DEBIAN_FRONTEND=noninteractive

apt-get update -q
apt-get install -q -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" apache2 mysql-server