selfhost.directory

The index of self-hostable projects — ranked, categorized and served with live updates.
Own your data and stop giving it to big tech.

docker-mailserver logo

Self-host docker-mailserver

v17.0.0

Fullstack mail server in a single Docker container

ReleaseOpen SourceMIT
Updated2 days ago
LanguageShell
Setup difficultyAdvanced
Stars
19 730
CPU
1 vCore
RAM
512MB RAM
Ports
25 (SMTP transfer (explicit TLS / STARTTLS)), 143 (IMAP4, explicit TLS via STARTTLS), 465 (ESMTP submission, implicit TLS), 587 (ESMTP submission, explicit TLS via STARTTLS), 993 (IMAP4, implicit TLS)
Docker
ghcr.io/docker-mailserver/docker-mailserver
Install with Docker Compose

What is docker-mailserver?

Should you self-host docker-mailserver?

docker-mailserver scores 78/100 on selfhost.directory (how scoring works) and ranks #2 of 16 in Mail Server. It has 19 730 GitHub stars, +841 in the last 30 days.

It shipped 3 stable releases in the past year. The latest, v17.0.0, came out on 5 November 2026. New versions land roughly every 5 weeks.

Setup is advanced: plan for several services and some ongoing maintenance. An official Docker image is available. It is MIT-licensed and written mostly in Shell.

Its closest alternative on selfhost.directory is Stalwart Mail Server (79/100, 15 780 stars). It scores higher overall, so compare the two before you pick. See docker-mailserver vs Stalwart Mail Server side by side.

Features

  • Admin setup CLI
  • Aliases, catch-all and multi-domain
  • Antivirus ScanningEnabled via ENABLE_CLAMAV=1; disabled by default.
  • DKIM / DMARC signing
  • External mail gathering
  • Fail2ban brute-force protectionENABLE_FAIL2BAN defaults to 0.
  • IMAP and POP3 mailboxes
  • LDAP account provisioner
  • OAuth2 / OIDC delegated loginOIDC account provisioning is not yet implemented.
  • Outbound SMTP relay
  • Sieve mail filtering
  • SMTP mail server
  • Spam Filtering
  • TLS certificate support
  • Update check notification

docker-mailserver README

Docker Mailserver

ci::status docker::pulls documentation::badge

📃 About

A production-ready fullstack but simple containerized mail server (SMTP, IMAP, LDAP, Anti-spam, Anti-virus, etc.).

  • Only configuration files, no SQL database. Keep it simple and versioned. Easy to deploy and upgrade.
  • Originally created by @tomav, this project is now maintained by volunteers since January 2021.

How to install docker-mailserver

Install docker-mailserver with Docker Compose

On the host, you need to have a suitable container runtime (like _Docker_ or _Podman_) installed.
DMS_GITHUB_URL="https://raw.githubusercontent.com/docker-mailserver/docker-mailserver/master"
wget "${DMS_GITHUB_URL}/compose.yaml"
wget "${DMS_GITHUB_URL}/mailserver.env"

Then edit compose.yaml and mailserver.env and start with docker compose up -d (use up/down, not start/stop).

How to configure docker-mailserver

  • OVERRIDE_HOSTNAME**empty** => Internally uses the `hostname --fqdn` command to get the canonical hostname assigned to the DMS container. => Specify an FQDN (fully-qualified domain name) to serve mail for. The hostname is required for DMS to function correctly **WARNING**: Setting OVERRIDE_HOSTNAME can have difficult to predict side effects: https://docker-mailserver.github.io/docker-mailserver/latest/config/enviro
  • LOG_LEVELSet the log level for DMS. This is mostly relevant for container startup scripts and change detection event feedback. Valid values (in order of increasing verbosity) are: `error`, `warn`, `info`, `debug` and `trace`. The default log level is `info`.
  • SUPERVISOR_LOGLEVELcritical => Only show critical messages error => Only show erroneous output **warn** => Show warnings info => Normal informational output debug => Also show debug messages
  • DMS_VMAIL_UIDSupport for deployment where these defaults are not compatible (eg: some NAS appliances): /var/mail vmail User ID (default: 5000)
  • DMS_VMAIL_GID/var/mail vmail Group ID (default: 5000)

docker-mailserver releases & version history

@ Every self-hosted release, weekly

One Monday email with the week's stable releases across the directory.

FAQ

How can I send quarantined mail to a mailbox?

Create an account for it and set the Amavis quarantine_to options in docker-data/dms/config/amavis.cf to that mailbox.

What to do in case of SPF/Forwarding problems?

Enable SRS (Sender Rewriting Scheme) with ENABLE_SRS=1.

How to ban custom IP addresses with Fail2ban?

Run the setup command to ban the address; the default bantime is 180 days and can be customized.

How can I delete all the emails for a specific user?

Create a devnull alias pointing at /dev/null and map that address to it in postfix-virtual.cf.

How can I configure my email client?

Log in with the full email address; IMAP on 143 or 993 with TLS, and SMTP submission on 587 or the preferred 465.

How do I update DMS?

Read the CHANGELOG first, then pull the new image and recreate the container with docker compose pull, down and up -d.

What kind of SSL certificates can I use?

Both RSA and ECDSA certificates, provided manually or from a mounted Let's Encrypt directory, with Traefik's acme.json also supported.

Can I use a naked/bare domain (i.e. no hostname)?

Yes, but you have to change Postfix's mydestination in postfix-main.cf and set the hostname accordingly.

Do you support multiple domains?

Yes, multiple domains work out of the box by adding accounts for each domain.

What are the system requirements?

Minimum is 1 vCore and 512MB RAM with some services such as ClamAV left disabled; recommended is 1 vCore with 2GB RAM and swap enabled.

Which operating systems are supported?

Linux is officially supported; Windows and macOS are not supported and problems have been reported there.

Where are emails stored?

In the mailbox path /var/mail/${domain}/${username}; since v9.0.0 custom user attributes can give accounts different mailbox layouts.

What kind of database are you using?

None — DMS requires no database; mail and configuration live on the filesystem, persisted with bind mounts or Docker volumes.

More in Mail Server

Rate this project

Click to rate — no account needed.

0 comments

Posting as guest
Loading comments…