If I run:

sudo apt-get --yes install postfix 


sudo bash -c 'yes | apt-get --yes install postfix'

an interactive prompt appears to configure postfix. I need to automate the installation of postfix (I can modify the configuration files after the install).

Is there some magic that lets me install postfix (and other package) without human intervention?


Set the DEBIAN_FRONTEND to noninteractive:

DEBIAN_FRONTEND=noninteractive apt-get ...

This is also applicable to dpkg --reconfigure, dpkg-configure, etc.

From man 7 debconf:

      This  is  the anti-frontend. It never interacts with you at all,
      and makes the default answers be  used  for  all  questions.  It
      might  mail  error messages to root, but that's it; otherwise it
      is completely silent and unobtrusive,  a  perfect  frontend  for
      automatic installs. If you are using this front-end, and require
      non-default answers to questions, you will need to  preseed  the
      debconf  database;  see  the section below on Unattended Package
      Installation for more details.

If you do set noninteractive, you should consider answering debconf questions by using debconf-set-selections.

  • 1
    please note, to use man 7 debconf on ubuntu 16.04 you need to first install debconf-doc, e.g. sudo apt-get install debconf-doc – the_velour_fog May 14 '16 at 5:34
  • @the_velour_fog or you can click the manpage link above and then click on 16.04 in the page that opens up. – muru May 14 '16 at 20:36
  • I can see the latest ubuntu images already include /etc/apt/apt.conf.d files prepared to handle the fact that apt is running inside a container. This includes Acquire::http::User-Agent-Non-Interactive "true" and post commands to clean /var/cache/apt. Is it still necessary to include DEBIAN_FRONTEND? – JulioHM Dec 15 '20 at 15:23
  • @JulioHM Acquire::http::User-Agent-Non-Interactive "true" doesn't sound like it's telling apt to be non-interactive. Sounds more like it's setting the HTTP User Agent. But yes, install, for example, tzdata (the timezone information package) with and without this set to see the difference. Most often you won't strictly need this, since Docker builds don't provide a terminal or any input, so any prompts for input EOF, but that's ugly and may not always lead to acceptable results. – muru Dec 15 '20 at 16:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.