【问题标题】:Dockerizing Postfix Relay serverDockerizing Postfix 中继服务器
【发布时间】:2018-09-04 20:19:31
【问题描述】:

我正在尝试构建一个专用于 Postfix SMTP 中继的 docker 容器。 经过几次尝试,我无法让它启动它的后缀服务。

这是 dockerfile

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"]

config.sh 文件包含:

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" > /etc/postfix/generic
postmap /etc/postfix/generic

我尝试在我的 dockerfile 中使用“postfix start”命令作为入口点,但容器立即关闭并返回代码 0。 我尝试通过删除 /sbin/postfix start 部分来使用 CMD 启动容器,我的容器启动并且稳定,但我必须手动启动 postfix 服务。然后我的继电器工作。 但这不是最理想的。

我找到了使用 supervisord 的解决方案,但我想让我的容器尽可能简单。 我的目标是拥有一个轻量级的可互换中继,以从托管在 docker 服务器上的应用程序发送邮件。

【问题讨论】:

标签: docker dockerfile postfix


【解决方案1】:

添加了后缀 v3.3.0 support for container:

容器支持:Postfix 3.3 将使用“postfix start-fg”在前台运行。

如果您使用的是较低版本,您可能需要使用 supervisord 或无限循环或无限睡眠来阻止容器退出。

【讨论】:

  • 谢谢。我将尝试深入研究这个主题。
  • 对不起,我找不到带有 Postfix 3.3 的存储库,我能找到的更高版本是 3.2。
  • @Aurelien ubuntu 18.04 上的默认后缀版本是 3.3
【解决方案2】:

我最终决定作弊并使用Supervisord。

【讨论】:

    【解决方案3】:

    你可以使用下面的命令来启动 postfix

    CMD ["/usr/libexec/postfix/master","-c", "/etc/postfix", "-d"]
    

    【讨论】:

      猜你喜欢
      • 2014-07-07
      • 2011-10-31
      • 2013-07-09
      • 1970-01-01
      • 2019-09-23
      • 1970-01-01
      • 2014-06-01
      • 2014-09-27
      • 2019-02-15
      相关资源
      最近更新 更多