Docker image for Postfix 3.11.7 and Dovecot on Ubuntu 26.10.
1.4K
Postfix and Dovecot for virtual mailboxes stored in MySQL. Mail is delivered over LMTP into Maildir, and clients sign in through Dovecot.
ubuntu:26.10Asia/Dhaka/var/vmail/domain/user@domain127.0.0.0/8 and for SASL-authenticated usersORIGINATING so OpenDKIM signs itTLS certificates are read from ${CERT_LOCATION}/${PF_HOSTNAME}/fullchain.pem and key.pem. CERT_LOCATION defaults to /etc/nginx/certs.
Mount /var/vmail if mailboxes should survive a new container.
| Port | Service |
|---|---|
| 25 | SMTP |
| 465 | SMTPS |
| 587 | Submission |
| 143 | IMAP |
| 993 | IMAPS |
| 110 | POP3 |
| 995 | POP3S |
| Variable | Purpose |
|---|---|
PF_HOSTNAME | Public mail hostname. Also the certificate directory name |
PF_DOMAIN | Mail domain written to /etc/mailname |
PF_DB_HOST | MySQL host |
PF_DB_USER | MySQL user |
PF_DB_PASS | MySQL password |
PF_DB_NAME | MySQL database, normally the PostfixAdmin database |
PF_DKIM_SERVICE_NAME | OpenDKIM host or IP |
PF_DKIM_SERVICE_PORT | OpenDKIM port |
DMARC_SERVICE_NAME | OpenDMARC host or IP |
DMARC_PORT | OpenDMARC port |
| Variable | Purpose |
|---|---|
PF_RSPAMD_SERVICE_NAME | Rspamd host or IP. Omit it to skip Rspamd |
PF_RSPAMD_PORT | Rspamd port |
CERT_LOCATION | Directory that contains the certificate folder. Default: /etc/nginx/certs |
PF_DAILY_REPORT_RECEIVER_EMAIL | Address that receives the daily mail report |
PF_DAILY_REPORT_SENDER | Mailbox name only, such as support. The domain is always PF_DOMAIN. Default: support |
docker run -d --name postfix \
-p 25:25 -p 465:465 -p 587:587 \
-p 143:143 -p 993:993 -p 110:110 -p 995:995 \
-e PF_HOSTNAME=mail.example.com \
-e PF_DOMAIN=example.com \
-e PF_DB_HOST=mariadb \
-e PF_DB_USER=postfix \
-e PF_DB_PASS=change-me \
-e PF_DB_NAME=postfix \
-e PF_DKIM_SERVICE_NAME=opendkim \
-e PF_DKIM_SERVICE_PORT=41001 \
-e DMARC_SERVICE_NAME=opendmarc \
-e DMARC_PORT=10020 \
-e PF_DAILY_REPORT_SENDER=support \
-e [email protected] \
-v mail-data:/var/vmail \
-v certs:/etc/nginx/certs:ro \
webkutir/postfix:3.11.7
When PF_DAILY_REPORT_RECEIVER_EMAIL is set, startup writes /send-my-report.sh. The script sends yesterday’s Postfix summary. The date is calculated in the container timezone, Asia/Dhaka. The sender is PF_DAILY_REPORT_SENDER plus @ plus PF_DOMAIN. With the example above, that is [email protected], and the recipient is [email protected].
The schedule is a crontab on the Docker host. This runs the report every day at 06:15 host time:
sudo bash -c '(crontab -l 2>/dev/null | grep -v send-my-report.sh; echo "15 6 * * * docker exec postfix /send-my-report.sh") | crontab -'
Confirm it with:
sudo crontab -l
docker pull webkutir/postfix:latest