Skip to content

Self-host docker-mailserver

updated Jul 2026prices 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.

Key facts

CategoryMail Server
LicenseMIT
StackShell
Min RAM512 MB
Official imageyes
Measured idle RAM94 MB
Difficulty
Our recommendation

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.

Follow the docker-mailserver deploy guide →

What you need

  • Any VPS with at least 512 MB of RAM
  • A domain you control — most self-hosted setups need HTTPS in front of them
  • About the better part of a day
Where to host itaffiliate disclosure
Hetzner Cloudrun it on
From $23.59/mo · 2 vCPU / 4 GB / 80 GB · EU + US
Get Hetzner Cloud (opens in new tab)
Kamaterafree trial
From $4/mo · 1 vCPU / 1 GB / 20 GB · US + EU + Asia
Start free on Kamatera → (opens in new tab)
DigitalOceanalso works on
From $6/mo · 1 vCPU / 1 GB / 25 GB · US + EU + Asia
Deploy on DigitalOcean → (opens in new tab)

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 files
DMS_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

What you take on

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.

An alternative to

Head-to-head

More self-hosted tools

Mail Server

Mailcow

A full-featured, Docker-based mail server suite — Postfix, Dovecot, SOGo webmail, ActiveSync, antispam, and a polished admin UI — the popular self-hosted alternative to Google Workspace and Microsoft 365 for small teams. It is a heavier, multi-container stack: 6 GB of RAM is the minimum, 8 GB recommended. As with any self-hosted mail, expect to manage deliverability (SPF, DKIM, DMARC, and reverse DNS) so your mail reaches inboxes.
PHPShell
hardRead guide →
Mail Server

Mailu

A simple, full-stack mail server as a set of Docker images — SMTP/IMAP, webmail, antispam, and an admin panel generated by a setup wizard. A lighter, MIT-licensed self-hosted alternative to Google Workspace for personal and small-team email. As with any self-hosted mail, expect to manage deliverability (SPF, DKIM, DMARC, and reverse DNS) so your mail reaches inboxes.
PythonShell
hardRead guide →
Mail Server

Stalwart

An all-in-one, self-hosted mail server written in Rust — SMTP, IMAP, JMAP, and CalDAV/CardDAV in a single binary with a built-in admin UI. The modern, low-footprint way to run your own email instead of Google Workspace or Microsoft 365.
Rust
hardRead guide →
Code hosting

GitLab CE

The whole DevOps platform in one install: repositories, merge requests, issues, a built-in CI/CD runner fleet, container and package registries, and Pages. It is open core — the community edition is MIT, the ee/ directory behind the paid tiers is not — and it is by far the heaviest thing on this list.
RubyGoPostgreSQL
hardRead guide →

We use analytics cookies (Google Analytics, PostHog) to see which guides are useful. No ad networks, no cross-site tracking. See our privacy policy.