Aur*_*ien 3 docker dockerfile postfix
我正在尝试构建一个专用于 Postfix SMTP 中继的 docker 容器。经过多次尝试,我未能让它在其上启动 postfix 服务。
这是 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"]
Run Code Online (Sandbox Code Playgroud)
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
Run Code Online (Sandbox Code Playgroud)
我试图在我的 dockerfile 中使用“postfix start”命令作为入口点,但容器立即关闭并返回代码 0。我试图通过删除/sbin/postfix start部件来使用 CMD 启动容器,我的容器启动并稳定,但我有手动启动 postfix 服务。然后我的继电器工作。但那是次优的。
我找到了使用 supervisord 的解决方案,但我想让我的容器尽可能简单。我的目标是拥有一个轻量级的可互换中继,以从托管在 docker 服务器上的应用程序发送我的邮件。
| 归档时间: |
|
| 查看次数: |
6780 次 |
| 最近记录: |