postfix docker不会转发电子邮件

时间:2014-09-17 08:02:13

标签: email docker postfix-mta lxc

您好我正在尝试创建一个通过smtp服务器中继电子邮件的docker容器,我的Dockerfile如下 -

FROM ubuntu:trusty
MAINTAINER dev<dev@localhost.com>

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 postfix.dev.mail.com" >> 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 = postfix.dev.mail.com'
RUN postconf -e 'mydestination = postfix.dev.mail.com, mail.dev.giftcardmall.com, localhost.localdomain, localhost'
RUN postconf -e 'relayhost = atom.corp.ebay.com'
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 "dev.mail.com   devuser@dev.mail.com" > /etc/postfix/sasl_passwd
RUN postmap /etc/postfix/sasl_passwd

ADD postfix.sh /opt/postfix.sh
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"]

supervisord.conf:

[supervisord]
nodaemon=true

[program:postfix]
command=/opt/postfix.sh
autostart=true
autorestart=true

postfix.sh

#!/bin/bash
service postfix start
tail -f /var/log/mail.log

我正在尝试通过postfix.dev.mail.com安装postfix,supervisord和配置postfix来中继电子邮件。我按如下方式运行容器,

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

并运行echo "Hello world" | mailx -s "Hello world" user@mail.com

但我没有收到电子邮件。如果我在普通的ubuntu主机上做同样的事情,它运行正常。我也看到,当我运行图像时,默认情况下不启动容器后缀。有什么我做错了吗?

1 个答案:

答案 0 :(得分:0)

如果在/bin/bash命令末尾添加docker run,它将覆盖构建文件中的CMD。 运行supervisord 使用

  

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