5

I am installing mailutils via a dockerfile on an ubuntu image.

I do this via:

RUN apt-get install -y mailutils

However, on this line I get the following:

Please select the mail server configuration type that best meets your needs.

 No configuration:
  Should be chosen to leave the current configuration unchanged.
 Internet site:
  Mail is sent and received directly using SMTP.
 Internet with smarthost:
  Mail is received directly using SMTP or by running a utility such
  as fetchmail. Outgoing mail is sent using a smarthost.
 Satellite system:
  All mail is sent to another machine, called a 'smarthost', for delivery.
 Local only:
  The only delivered mail is the mail for local users. There is no network.

  1. No configuration  3. Internet with smarthost  5. Local only
  2. Internet Site     4. Satellite system

When I do exactly the same thing with a Debian image I do not get this option.

I use the -y prefix to handle all the yes/no installation questions when using a Dockerfile. How do I handle an option like this? I have tried adding a -2 prefix.

Is there a way to skip this? Why does ubuntu require this when debian does not? I have checked and the mail functions correctly with debian despite not requiring this input.

LearningSlowly
  • 8,641
  • 19
  • 55
  • 78

2 Answers2

8

Use the following dockerfile:

FROM ubuntu:latest
ENV DEBIAN_FRONTEND="noninteractive"
RUN apt-get update && apt-get install -y mailutils

The important part is setting debconf to noninteractive mode.

Farhad Farahi
  • 35,528
  • 7
  • 73
  • 70
2

You can also use this trick with something like

FROM ubuntu:latest
RUN apt-get update && apt-get install -y
RUN echo "postfix postfix/mailname string your.hostname.com" | debconf-set-selections &&\
        echo "postfix postfix/main_mailer_type string 'Internet Site'" | debconf-set-selections &&\
        apt-get install -y mailutils
user2599522
  • 3,005
  • 2
  • 23
  • 40