postfix docker doesn't relay emails

Hi I am trying to create a docker container that relays emails via a smtp server, my Dockerfile is as follows –

FROM ubuntu:trusty

ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update
RUN echo "postfix postfix/main_mailer_type string Internet site" > preseed.txt
RUN echo "postfix postfix/mailname string" >> preseed.txt
RUN debconf-set-selections preseed.txt
RUN DEBIAN_FRONTEND=noninteractive apt-get install -q -y postfix

RUN apt-get -y install postfix supervisor sasl2-bin opendkim opendkim-tools mailutils vim

RUN postconf -e 'myhostname ='
RUN postconf -e 'mydestination =,, localhost.localdomain, localhost'
RUN postconf -e 'relayhost ='
RUN postconf -e 'smtp_sasl_auth_enable = yes'
RUN postconf -e 'smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd'
RUN postconf -e 'smtp_sasl_security_options ='
RUN echo "" > /etc/postfix/sasl_passwd
RUN postmap /etc/postfix/sasl_passwd

ADD /opt/
ADD supervisord.conf /etc/supervisor/conf.d/supervisord.conf
EXPOSE 22 25 110 143 465 587 993 995
CMD ["sh", "-c", "/usr/bin/supervisord","service postfix start"]


  • Installation of Docker on Debian 8
  • Docker 'killing' my program
  • how to use docker and salt provisioning [closed]
  • plugin/docker : Is passing id_rsa priv key using build_args correct?
  • Running the WSO2 Application Manager docker image with custom configuration
  • how to setup dns nameserver in docker permanently in user-defined network?
  • [supervisord]

    service postfix start
    tail -f /var/log/mail.log

    I am trying to install postfix,supervisord and configure postfix to relay email via I run the container as follows,

    sudo docker run -p 22 -p 25 -p 110 -p 143 -p 465 -p 587 -p 993 -p 995 -i -t 7c9cc85e34c1 /bin/bash

    And run echo "Hello world" | mailx -s "Hello world"

    But I don’t receive the email. If I do the same in a normal ubuntu host, it works fine. I also see that when I run the image as container postfix is not started by default. Is there something I am doing wrong?

  • Docker breaks autofs directory in V1.5, used to work in V1.3.3
  • docker container started in Detached mode stopped after process execution
  • Does docker community edition is available for docker version 1.12?
  • Mounting private GitHub repository into a pod's volume
  • Private Network broken in Vagrant with Docker
  • Broadcasting UDP from within a Docker container
  • One Solution collect form web for “postfix docker doesn't relay emails”

    IF you add the /bin/bash at the end of the docker run command it overrides the CMD in the build file.
    To run the supervisord

    sudo docker run -p 22 -p 25 -p 110 -p 143 -p 465 -p 587 -p 993 -p 995 -i -t 7c9cc85e34c1

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.