Analytics cookies only (Google Analytics, PostHog). No ad networks, no cross-site tracking. See our privacy policy.
Self-host docker-mailserver
updated Jul 2026deployed by usprices checked · Jul 2026Install verified on Ubuntu 26.04 · Jul 2026 · how we test
We earn commissions when you shop through the links below. Full disclosure →
A production-ready, config-driven mail server in a single container — Postfix, Dovecot, and a choice of Amavis/SpamAssassin or Rspamd antispam, with no database and no web UI, configured entirely from plain files. A lightweight, MIT-licensed self-hosted alternative to Google Workspace email. As with any self-hosted mail, expect to manage deliverability (SPF, DKIM, DMARC, and reverse DNS) so your mail reaches inboxes.
Pick docker-mailserver when you want a mail server you administer from a shell, not a browser: one MIT-licensed container of Postfix, Dovecot, Rspamd, Amavis, SpamAssassin, ClamAV, OpenDKIM/OpenDMARC and Fail2ban, configured entirely through `mailserver.env` and the bundled `setup` script — "only configuration files, no SQL database". It has the smallest RAM floor in this hub and is the easiest to version-control, and it is the least forgiving if you expected a web UI: there isn't one.
Paid link — we earn a commission if you shop through it.
Install
Run these commands on your server:
# docker-mailserver — single container, no web UI; config from plain filesDMS_URL="https://raw.githubusercontent.com/docker-mailserver/docker-mailserver/master"wget "${DMS_URL}/compose.yaml" && wget "${DMS_URL}/mailserver.env"# Replace the hostname: mail.example.com line in compose.yaml with your# own FQDN first — it ships as a placeholder and becomes your SMTP banner.docker compose up -d && docker exec -ti mailserver setup email add user@example.com
docker-mailserver ships with almost everything off; the defaults in `mailserver.env` decide what you actually get:
non-negotiableTLS is off out of the box — SSL_TYPE= empty means SSL disabled. The usage docs say "You definitely want to setup TLS"; set SSL_TYPE=letsencrypt (or manual/custom) before any client connects.
non-negotiableClamAV, Rspamd, SpamAssassin and Fail2ban all default to 0; Amavis and OpenDKIM default to 1. Turn on what you need deliberately, and remember that enabling ClamAV changes the memory picture — our 512 MB floor is our estimate for the defaults, not for a ClamAV-enabled stack.
non-negotiableThe compose file ships with hostname: mail.example.com as a placeholder; replace it with your real FQDN before first start, because it becomes the server's identity. The docs also require a static IP, a PTR record you can set, and MX and A records before mail flows.
non-negotiableThere are no accounts until you create one: docker exec -ti mailserver setup email add user@example.com. Every later change — aliases, DKIM keys, quotas — goes through the same setup script or the config directory, not a UI.
docker-mailserver used 94 MB of RAM at idle on GCP e2-standard-2 · Ubuntu 26.04 LTS · Docker 29.7.2 (first boot, measured Aug 2026). We list a minimum of 512 MB.
Is the docker-mailserver install snippet verified?
The docker-mailserver install snippet is marked verified on Ubuntu 26.04 (Jul 2026).