From 1dab5833efb2f42421c2740a226ffb9f92bc306c Mon Sep 17 00:00:00 2001 From: Sergey Trofimovsky Date: Tue, 29 Nov 2016 14:54:35 -0700 Subject: [PATCH] mynetworks env variable, some cleanup --- Dockerfile | 12 ++++++------ README.md | 11 +++++++++++ assets/install.sh | 18 +++++++++++++++--- 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5395bf5..ccb9bd1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,12 +4,12 @@ MAINTAINER Elliott Ye # Set noninteractive mode for apt-get ENV DEBIAN_FRONTEND noninteractive -# Update -RUN apt-get update - -# Start editing -# Install package here for cache -RUN apt-get -y install supervisor postfix sasl2-bin opendkim opendkim-tools +RUN apt-get update && apt-get install -y \ + opendkim \ + opendkim-tools \ + postfix \ + supervisor \ + sasl2-bin # Add files ADD assets/install.sh /opt/install.sh diff --git a/README.md b/README.md index 955a64c..8c4c305 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,17 @@ TLS and OpenDKIM support are optional. --name postfix -d catatnight/postfix ``` +4. (Optional) Configure postfix to allow relaying from a local docker network (containers in the same network): +``` +network=`docker network inspect --format='{{range .IPAM.Config}}{{.Subnet}}{{end}}' my_docker_network` + +docker run -d --name smtp \ + --net=my_docker_network \ + -e maildomain=mydomain.localhost \ + -e mynetworks=127.0.0.0/8,$network \ + myrepo/postfix +``` + ## Note + Login credential should be set to (`username@mail.example.com`, `password`) in Smtp Client + You can assign the port of MTA on the host machine to one other than 25 ([postfix how-to](http://www.postfix.org/MULTI_INSTANCE_README.html)) diff --git a/assets/install.sh b/assets/install.sh index 0b2aaff..ed63617 100755 --- a/assets/install.sh +++ b/assets/install.sh @@ -5,6 +5,12 @@ if [[ -a /etc/supervisor/conf.d/supervisord.conf ]]; then exit 0 fi +if [ -z "$maildomain" ]; then + echo '$maildomain env variable not set, exiting' + exit 1 +fi +echo "*** maildomain = $maildomain" + #supervisor cat > /etc/supervisor/conf.d/supervisord.conf <> /etc/postfix/sasl/smtpd.conf <> /etc/opendkim/SigningTable <