title: Dockerizing Postfix Relay server
body: <p>I'm trying to build a docker container dedicated to a Postfix SMTP relay.
  I fail to make it start the postfix service on it after several tries.</p>
  
  <p>Here's the dockerfile</p>
  
  <pre><code>FROM centos:centos7
  LABEL Author = "Aurelien HUGON 
  LABEL Description = "DOCKERFILE : Creates a Docker Container for a Relay Postfix smtp server"
  
  #Update and soft
  RUN yum update -y
  
  RUN yum install -y nano postfix
  
  #Clean install
  RUN yum clean all
  
  #Config
  COPY /cfg/config.sh /
  RUN chmod +x config.sh
  RUN ./config.sh
  RUN touch /var/log/maillog
  
  CMD ["sh", "-c", "/sbin/postfix start", "tail -f /var/log/maillog"]
  </code></pre>
  
  <p>The config.sh file contains :</p>
  
  <pre><code>postconf -e 'myhostname = myserverhostname'
  postconf -e 'mydomain = domain.com'
  postconf -e 'myorigin = $mydomain'
  postconf -e 'smtp_generic_maps = hash:/etc/postfix/generic'
  postconf -e 'mynetworks = 127.0.0.1/32 192.168.0.0/16 172.16.0.0/12 10.0.0.0/8 [::1]'
  postconf -e 'mynetworks_style = class'
  postconf -e 'inet_interfaces = all'
  postconf -e 'relayhost = [dedicated SMTP server]'
  echo "generic@adress.com generic2@adress2.com" &gt; /etc/postfix/generic
  postmap /etc/postfix/generic
  </code></pre>
  
  <p>I tried to use the "postfix start" command as entrypoint in my dockerfile but the container instantly shuts down with return code 0.
  I tried to start the container with the CMD by removing the <code>/sbin/postfix start</code> part, my container starts and is stable, but i have to start the postfix service manually. And then my relay works.
  But that's suboptimal.</p>
  
  <p>I found solutions using supervisord, but i want to keep my container as simple as possible.
  My goal is to have a light interchangeable relay to send my mails from my application hosted on the docker server.</p>