Simple postfix image based on latest alpine linux
7.2K
A lightweight, secure, and minimal Postfix relay server based on Alpine Linux. Designed to forward emails from local services or networks to an upstream SMTP server (like Gmail, Sendgrid, or your own mail server).
{{ DOMAIN }} with environment variables at runtime.postfix.cf) and .map files (e.g., transport, virtual) via the /overrides volume.services:
postfix:
image: ghcr.io/marcellopercoco/alpine-postfix:latest
container_name: alpine-postfix
environment:
- DOMAIN=example.com
- HOSTNAME=mail
- RELAYHOST=[smtp.provider.com]:587
- RELAYNETS=172.16.0.0/12
- MESSAGE_SIZE_LIMIT=52428800
volumes:
- ./overrides:/overrides
ports:
- "25:25"
restart: always
The entrypoint script uses the following environment variables to dynamically configure Postfix:
| Variable | Default | Description |
|---|---|---|
DOMAIN | localdomain | Sets the mydomain and myorigin variables. |
HOSTNAME | localhost | Sets the myhostname variable. If it does not contain a dot ., it is automatically set to HOSTNAME.DOMAIN. |
MESSAGE_SIZE_LIMIT | 50000000 | Defines the maximum size of a message in bytes (defaults to ~50MB). |
RELAYNETS | (empty) | Comma/space-separated list of IP networks allowed to relay mail through this server. |
RELAYHOST | (empty) | The upstream SMTP server where all mail will be forwarded (e.g. [smtp.sendgrid.net]:587). |
You can further customize Postfix settings by mounting a folder to /overrides containing any of the following:
postfix.cfAny valid Postfix configuration line in this file will be parsed and applied using postconf -e at startup.
Lines starting with # or empty lines are ignored.
Example /overrides/postfix.cf:
# Increase transport connect timeout
smtp_connect_timeout = 60s
# Use custom banner
smtpd_banner = $myhostname ESMTP
*.map filesAny file ending in .map (e.g., transport.map, virtual.map) will be:
/etc/postfix/postmap to generate the matching lookup database.map is deleted, leaving only the .db files with root:root and 0600 permissions)Content type
Image
Digest
sha256:81262aff9…
Size
10.4 MB
Last updated
3 days ago
docker pull cobra1978/alpine-postfix