Postfix running in a docker container to be used as a mail relay
10K+
A container running postfix intended to be used as an internal mail relay to the outside world.
Image hosted at: ghcr.io/jchonig/postfix
Optionally authenticate incoming connections with SASL
docker create \
--name=posfix \
-e PUID=1000 \
-e PGID=1000 \
-v </path/to/appdata/config>:/config \
-p 25:25 \
--restart unless-stopped \
ghcr.io/jchonig/postfix
Compatible with docker-compose v2 schemas.
---
version: "2"
services:
postfix:
image: ghcr.io/jchonig/postfix
environment:
- PUID=1000
- PGID=1000
volumes:
- </path/to/appdata/config>:/config
- data:/data
port:
- 25
restart: unless-stopped
volumes:
data:
| Volume | Function |
|---|---|
| 25 | The incoming SMTP port |
| Env | Function |
|---|---|
| PUID=1000 | for UserID - see below for explanation |
| PGID=1000 | for GroupID - see below for explanation |
| USE_SASL=yes | Use sasl for user authentication |
| USE_SASLAUTHD=yes | Use saslauthd |
| USE_DKIM=yes | Not yet implemented |
| USE_TLS=yes | Enable STARTTLS for incoming connections on port 25 |
| USE_SMTPS=yes | Enable TLS wrapper on port 465 |
| MYHOSTNAME=example.com | Configure postfix myhostname parameter |
| MYORIGIN=example.com | Configure postfix myorigin parameter |
| MYDESTINATION= | Configure postfix mydestination parameter |
| MASQUERADE_DOMAINS=example.com | A comma seperated list of domains to masquerade |
| SMTPD_TLS_SECURITY_LEVEL=may | Configure the level of TLS required on incomming connections |
| BOUNCE_QUEUE_LIFETIME=1d | Configure the postfix bounce queue lifetime |
| INET_PROTOCOLS=all | Set postfix inet_protocols (e.g. all, ipv4, ipv6) |
| RELAYHOST=[host]:port | Outbound relay host (e.g. [smtp-relay.gmail.com]:587) |
| Volume | Function |
|---|---|
| /data | Persistent data (i.e. /data/spool) |
| /config | All the config files reside here |
RELAYHOST is set, outbound TLS (smtp_tls_security_level=encrypt) is enabled automatically
/config/sasl.passwd, which uses standard postfix sasl_passwd format: one entry per line of relayhost user:password[smtp-relay.gmail.com]:587 [email protected]:app-password/config/sasl.passwd is read directly by postfix on demand — no rebuild step needed when the file changesRELAYHOST=[smtp-relay.gmail.com]:587 and generate an App Password for the account; enable the SMTP relay service in Google Workspace Admin → Apps → Gmail → RoutingContent type
Image
Digest
sha256:2f3290358…
Size
30.1 MB
Last updated
6 days ago
docker pull jchonig/postfix