Self-hosted email servers on Docker vs Kubernetes vs VMs

Docker, Kubernetes and virtual machines each host a self-hosted email server differently. This page shows which model fits which team, and what sizing, high availability, upgrades and backup demand from each.

On this page

Which deployment model fits a self-hosted email server

A single-host Docker stack suits a small team with one administrator who wants the mail components packaged together and accepts one machine as the whole failure domain. Kubernetes suits a team that already operates clusters, runs its own storage and ingress, and has documented Kubernetes guidance to follow. Mailu's general documentation covers both Docker Compose and Kubernetes setup, so that path is documented, but the cluster team still owns it. Virtual machines suit teams that want OS-level control and standard patching on the host, with the mail stack managed like any other server. Pick the model your team already operates well, since the mail features are set mostly by the software you install.

The model mostly changes availability, upgrade and backup work, and it changes the mail features far less. A mailcow host needs at least 6 GiB of RAM plus 1 GiB of swap by default, and 8 GiB is recommended for about 5 to 10 users, so size the machine or nodes for the whole stack before you decide where it runs. Incoming TCP ports 25, 465, 587, 143, 993, 110, 995, 4190, 80 and 443 must reach the stack whichever model you pick, so the load balancer and ingress rules become part of your design. Treat high availability as something to verify. Dovecot's 2.3 to 2.4 upgrade guide records that version 2.4 removed replication and Director support from the Community Edition, so do not assume a second IMAP node replicates mailboxes until you confirm which Dovecot edition and replication design your stack uses.

Before you choose, put three questions to whoever will run the stack. First, who patches the host and on what cycle, since VM and Kubernetes teams patch different layers and a mail server cannot be taken down casually. Second, where do mailbox data and database backups live, and has anyone restored them to a clean host? Third, if you are on Kubernetes, which storage class holds the mail and database volumes, and does the cluster team accept a stateful mail workload? Your answers usually settle the deployment model before any feature comparison does. Confirm each answer against the vendor's installation and upgrade notes before you commit.

How a self-hosted email server compares on Docker, Kubernetes and VMs

This table compares Docker, Kubernetes and virtual machines as hosts for a self-hosted email server across seven operating factors. Read each row against your team's existing skills and the mail stack you plan to run. The main takeaway: Docker is the lightest path for one stack, Kubernetes pays off mainly with an existing platform team, and VMs suit teams that want familiar patching and snapshots.

FactorDockerKubernetesVMs
Host footprintOne host or VM running separate containers. mailcow's system requirements list at least 6 GiB RAM plus 1 GiB swap.Cluster nodes, storage and ingress added on top of the mail stack. Confirm node sizing with the stack maintainer.One guest OS per mail server, with its own disk and RAM. mailcow recommends 8 GiB for about 5 to 10 users.
Who patches the base OSYour team patches the host OS. Image updates arrive as new pulls, so confirm the stack's update cadence.Your platform team patches nodes and cluster components. You still own mail container images and their updates.Your team patches the guest OS and mail packages on each server. Confirm the stack's supported OS versions.
High availability designUsually one host with restart policies. Confirm any multi-host or mailbox replication path with the stack vendor.Replicas depend on how each mail component stores state. Confirm which parts can run more than one instance.Failover usually means a standby host or hypervisor features. Dovecot 2.4 Community dropped replication and Director.
Upgrade pathPull new images and restart containers. Read release notes for config or schema changes before each pull.Staged rollouts via manifests, if the stack publishes them. Mailu documents Kubernetes guides; confirm upgrade steps per version.Package or source upgrades in place, with a snapshot taken before each step. Confirm major-version migrations, such as Dovecot 2.3 to 2.4.
Backup scopeVolumes, database dumps, config directories and mail storage. Confirm the stack's documented backup procedure.Persistent volumes, databases, secrets and deployment manifests. Restore tests must cover cluster configuration too.Whole-VM snapshots plus application-level mail and database backups. Snapshots alone may not give a consistent mail restore.
Skills requiredContainer runtime, Linux, DNS, TLS and mail protocols. Lowest added skill set if the team already runs containers.Cluster operations, storage, ingress and networking on top of mail DNS and TLS. Highest skill need unless a platform team exists.Linux administration and mail server operations. Familiar to most mail teams, but patching and backups are manual unless automated.
Fit for compliance evidencePinned image tags, container logs and host records can be evidenced. Confirm image sourcing and log retention with your assessor.Cluster RBAC, audit logs and policy records add evidence but widen scope. Confirm which controls your assessor expects.Clear host boundaries and patch records suit traditional audit scopes. Confirm mail log retention and evidence with your assessor.

What runs inside each deployment model

Each deployment model changes where the line sits between what your team configures and what it inherits from the vendor or the platform. The four cards below cover the container stack, the cluster option, the virtual machine and the single-host appliance. Read them against your team's skills, since each model asks for different operating work after go-live.

Docker Compose stack with mailcow

mailcow runs Postfix, Dovecot, Rspamd, SOGo, ClamAV, MariaDB, Redis, Nginx and Unbound in separate containers, so each service has its own image, restart behavior and log stream. That split makes upgrades and troubleshooting per-container work, and it means you check health, volume placement and backup scope for each one. Ask who applies mailcow image updates, how you test them before production and which MariaDB and Redis versions ship in each release. Your team still owns the Docker host, its patching and the backups of mail volumes.

mailcow documentation

Kubernetes option with Mailu

Mailu's documentation includes Kubernetes setup guides, alongside its Docker Compose guide, so a cluster deployment starts from published instructions. Confirm the chart and storage design with the Mailu project before you build on it, including how mailbox volumes are provisioned, backed up and restored. Plan the inbound routing as well: SMTP, submission, IMAP, POP3, ManageSieve and HTTPS traffic must reach the cluster on ports 25, 465, 587, 143, 993, 110, 995, 4190, 80 and 443, and your ingress has to carry them.

Mailu general docs

Virtual machine with services on the OS

On a virtual machine, the mail services are installed directly on the operating system, with no container layer between them and the host. The operator owns every service: package versions, configuration files, service restarts, log rotation and security patches for Postfix, Dovecot, the web tier and the database tiers you choose. Dovecot 2.4 Community Edition no longer includes replication or Director support, so plan mailbox failover with tooling your team operates itself. Write the upgrade runbook before go-live, and confirm that your snapshot and backup tooling captures mail data consistently.

Dovecot 2.4 upgrade guide

Single-host appliance with Mail-in-a-Box

Mail-in-a-Box turns a fresh Ubuntu 22.04 LTS machine into a mail server with Postfix, Dovecot, Roundcube, Nextcloud contacts and calendars, Z-Push and its own nsd4 DNS server. It offers no user-configurable setup options, so the design choices are made for you and you adopt them as delivered. Check the DNS handover first: the appliance runs its own nsd4 server, so confirm how that fits your registrar, existing zones and any other records on the domain. Confirm that the Ubuntu 22.04 base also fits your OS patching policy before installation.

Mail-in-a-Box repository

How the choice follows from team skills and availability needs

The path starts from the platform your team already runs: no cluster, an existing Kubernetes cluster or a VM estate. With no cluster, a Docker suite such as mailcow or Mailu fits, and the next question is whether auditors need log and backup records. For Kubernetes or VMs, the first split is whether mail storage must survive a node failure. If it does, confirm the Dovecot topology before going further, because Dovecot 2.4 Community Edition no longer includes replication or Director. If not, confirm the mailbox count and keep a single instance. Auditor evidence is the final gate on each branch.

Decision path from current platform to the next check before deployment.

How much RAM a self-hosted email server needs on Docker

Plan for at least 6 GiB of RAM and 1 GiB of swap for a default mailcow install, and treat 8 GiB as the recommended starting point for roughly 5 to 10 mailboxes. Those are mailcow's own published requirements for a single Docker host running Postfix, Dovecot, Rspamd, SOGo, ClamAV, MariaDB, Redis, Nginx and Unbound as separate containers. ClamAV and Rspamd deserve the closest attention, because antivirus scanning and spam scoring run against every inbound message. Treat the published figures as a starting floor for a small team, and expect a growing mailbox count to need its own sizing. Confirm the current numbers on the requirements page before you order hardware, since they can change between releases.

Mailbox count is not the only number that moves memory. Spam and antivirus load follows inbound mail volume, so a small team on a busy domain can outgrow its host before it adds a single user. Webmail through SOGo keeps browser sessions open all day, which tends to cost more than IMAP clients that sync occasionally. Log retention grows disk use, and the cost of searching old logs depends on how you have configured them. Rank these four drivers for your own organization before you pick a size, since the largest one should set the headroom you buy. Moving the same services to VMs or Kubernetes does not carry these numbers across. Container limits, node sizing, swap behavior and storage layout each need their own sizing exercise on that platform.

Before you provision a host, ask mailcow, or whichever project you shortlist, for sizing guidance written against your mailbox count, expected inbound volume and webmail share. Ask whether their figures assume a specific mail volume and what they recommend above that. Then test under load before cutover. Replay representative inbound mail, including large attachments, run concurrent IMAP and webmail sessions, and watch RAM, swap use, disk I/O and the latency of spam and virus scanning. Keep headroom for peaks, and rerun the test after any change to the stack, such as an upgrade or a new antispam rule.

Upgrades, backups and monitoring on each model

This table compares what each model asks of the operator for upgrades, backups, monitoring and skills. Read across a row to see where the work sits: in the container images, in the cluster and its storage, or on each virtual machine's operating system. The main takeaway is that mailbox, database and configuration backups are needed on all three models, and Kubernetes and VMs add platform upgrade work on top.

AreaDocker stackKubernetesVirtual machines
UpgradesPull the new release images, recreate the containers and run any migration steps the project documents.Upgrade the cluster, then the mail chart or manifests, rolling stateful pods in a controlled order.Patch the OS, then upgrade the mail packages, repeating on every node in a multi-node setup.
Platform layer upgradesUpgrade the Docker Engine and host OS on their own schedule, since both sit under the containers.Cluster upgrades, node pools, network and storage drivers each add a separate upgrade track.Patch the hypervisor or cloud host where the VMs run, on its own schedule.
RollbackRestore the previous image tag and a pre-upgrade backup, if the schema changes allow it.Revert the release, but database schema and volume changes may still need a restore.Restore the VM from a snapshot or image, or downgrade packages if the vendor supports it.
Mailbox data backupsMailboxes sit in bind mounts or named volumes; back them up with the host tooling you already run.Mailboxes sit on PersistentVolumeClaims; use volume snapshots or a backup tool that supports your storage class.Mailboxes sit on VM disks or attached storage; choose file-level or image backups and confirm consistency.
Database backupsDump the database from its container before copying files, since live database files may copy inconsistently.Use a database dump job or operator; plain volume snapshots may not give a consistent database copy.Run the database's native dump or backup tool on the host, on the schedule your change process sets.
Configuration backupsKeep the compose file, environment file and DNS records in version control, with secrets in a vault.Keep manifests or chart values in Git, store secrets in a secret manager and back up cluster objects.Back up mail service configuration and OS config directories, and record manual changes made on the host.
MonitoringTrack container health, restart counts, volume disk, mail queue size and certificate expiry.Track pod restarts, PersistentVolume usage, node pressure, mail queue size and certificate expiry.Track host metrics, service status, mail queue size, disk and certificate expiry with your existing agent.
SkillsLinux, Docker Compose, DNS and mail protocol basics; the stack hides most service wiring.Cluster operations, storage classes, ingress and TLS, plus mail protocol knowledge for the team that owns it.Linux administration, package patching and direct configuration of each mail component.
What to confirm firstUpgrade notes for the image tag, migration steps and configuration keys, checked against your change window.Chart or manifest release notes, supported Kubernetes versions and volume migration steps, run through your change process.Package release notes, OS support status and the vendor's upgrade path, checked against your change process.

Which team should run each deployment model

A small IT team without a cluster usually brings general Linux administration, DNS and certificate work, and some Docker experience from other services. A dockerized suite such as mailcow or Mailu puts the whole stack on one host, which keeps the moving parts familiar, but the team still owns deliverability, DNS records, TLS renewal and restores.

  • Skills already in place. Linux administration, Docker host management, and DNS and TLS basics. Confirm that someone has previously worked through a mail queue or a bounced message investigation.
  • Work to take on. Host sizing (mailcow's system requirements list at least 6 GiB of RAM plus 1 GiB of swap by default and recommend 8 GiB for about 5 to 10 users), container updates, backups of mailbox and database volumes, and firewall rules for the mail ports.
  • Work not to take alone. Sending reputation problems, blocklist removal and any legal hold or eDiscovery request. Arrange a second person or an outside reviewer for these before go-live.
  • First question to answer. Who responds when the single mail host fails on a weekend, and how long can the business work without email?

Check whether one host with a tested restore meets the outage tolerance your users and auditors expect.

Why high availability is the hard part of a self-hosted email server

Adding containers or nodes does not by itself make a self-hosted mail server highly available. Failover is decided by two components: the mailbox storage layer and the IMAP service that clients connect to. In a Docker, Kubernetes or virtual machine build, a second copy of the mail stack does not help during an outage if it cannot read the same mailboxes, or if the IMAP service has no safe way to hand a session over to it. Extra replicas also add moving parts, such as shared volumes and health checks, that can fail on their own. Before you choose a platform, map which component owns mailbox state, which owns the IMAP session, and what promotes a standby when the active one fails.

Start with the upstream documentation. The Dovecot 2.3 to 2.4 upgrade guide states that Dovecot 2.4 removed replication and Director support from the Community Edition, and that the Director role has been replaced by the Dovecot Pro Palomar architecture. Director was the component that kept each user on a consistent backend, so a design that depended on it or on replication has to be designed again for the new version. If you run a free edition, that design work and its testing fall to your team, and Palomar belongs to the Dovecot Pro offering, so its cost belongs in your comparison. Ask Dovecot, or your packaging provider, which high availability features remain in the exact edition and version you plan to run, and keep the answer in writing.

A team on a free edition has to design failover at the storage and DNS layers and confirm each option with the vendor. At the storage layer, decide whether the mailbox volume is replicated or shared, how a standby is promoted, and whether the file locking behavior of your filesystem is supported for mail storage. At the DNS layer, a second MX record gives senders a fallback, but it does not move mailboxes, so the backup host must either deliver to the same store or queue mail until the primary returns. Test failover before you rely on it: in a copy of your production setup, stop the active IMAP and SMTP services, send a test message during the outage, promote the standby, and confirm that clients reconnect and that the message is readable. Record each step and the observed recovery time.

What buyers ask before choosing a deployment model

How much effort does a Docker, Kubernetes or VM mail server take to run?

Effort follows the number of moving parts your team operates, so the hosting model changes where that effort lands. A Docker Compose suite such as mailcow runs Postfix, Dovecot, Rspamd, SOGo, ClamAV, MariaDB, Redis, Nginx and Unbound in separate containers, so your team patches and monitors each container along with the host. Kubernetes adds cluster work on top of the mail stack, including ingress, persistent volumes and cluster upgrades. Mailu publishes both Docker Compose and Kubernetes setup guides, so the same product can run on either path. A single-machine appliance such as Mail-in-a-Box, built on a fresh Ubuntu 22.04 LTS machine, has the fewest moving parts, but it offers no user-configurable setup options. Confirm with the vendor and your platform team which of these operations they will own.

What drives the cost of running a self-hosted mail server?

Cost comes from the people and infrastructure that run the service, and most of it recurs after the first build.

  • Staff time: setup work first, then patching, monitoring, alert response and upgrades, which repeat for the life of the service.
  • Host count: each host, cluster node or VM carries its own operating system, patching and capacity planning.
  • Storage: mailboxes, backups and logs grow over time and need retention decisions.
  • Monitoring and patching: tooling, alert rules and change windows apply to every container, VM or cluster component.

Ask any quote to split one-time build work from recurring operations, and to name who pays for each line. DeployOpen quotes follow from a written scope, and DeployOpen does not publish a price list.

How much memory and how many hosts does a Docker mail stack need?

A single Docker host is the simplest starting point, and the mailcow requirements set the baseline for it. The mailcow system requirements call for at least 6 GiB of RAM plus 1 GiB of swap by default, and recommend 8 GiB for about 5 to 10 users. Those figures describe one mailcow stack, so the host count depends on whether you add a second host for redundancy, a separate backup target or a Kubernetes cluster. Mail also needs inbound TCP ports 25, 465, 587, 143, 993, 110, 995, 4190, 80 and 443, which apply to any self-hosted mail server offering SMTP submission, IMAP, POP3 and webmail, so plan firewall and load balancer rules before the host goes live. Confirm sizing for your mailbox count and peak load in writing before you buy hardware.

How long does the initial setup of a self-hosted mail server take?

Setup time depends on the scope, so confirm the timeline in a written scope before you plan a cutover. The main drivers are the number of domains and mailboxes, whether existing mail must move in, the DNS and TLS work each domain needs, identity integration with your SSO, backup and restore testing, and the hardening review your security team requires. Each of these adds tasks that a scope should name separately. Most DeployOpen engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts, so ask for a dated plan with a sign-off point at each stage.

What does a self-hosted mail deployment need from our internal team?

Your team needs named owners for the parts that stay in your environment after handover, and the skills depend on the model you pick. At minimum, plan for someone who manages DNS records and TLS certificates, someone who runs the hosts, containers or cluster, someone who restores backups and tests the restore, and someone who receives and acts on monitoring alerts. A Kubernetes model adds cluster administration skills, and a Docker model adds container and host skills. Identity needs an owner too, because SSO, admin accounts and the directory must match your access policy. Decide who approves changes, who holds admin credentials and who is on call for mail delivery problems before the build starts. Ask the implementer to name what they will hand over and what they will keep operating.

Can a small team run a Docker mail stack without outside help?

Yes, if the team can operate Linux hosts, read container logs, apply upgrades in a tested order and restore backups on request. A Docker stack like mailcow runs several services in separate containers, so the team must know which container handles delivery, storage and filtering before an incident starts. The hardware baseline is documented, so operating skill is usually the constraint to assess. Check three things before you commit: whether someone can own on-call for delivery issues, whether the team has tested a full restore, and whether upgrade windows fit your change process. If any answer is no, budget for ongoing support. DeployOpen offers ongoing support, upgrades and continuous testing as retainers, and it documents the environment so your team can take over later.

Does Kubernetes improve high availability for a mail server?

Kubernetes restarts and reschedules workloads, but it does not replicate mailbox data by itself, so it does not settle mail high availability on its own. Mail availability depends on how mailbox storage, queues and the IMAP layer are replicated and failed over. Dovecot 2.4 removed replication and Director support from its Community Edition and replaced the Director role with the Dovecot Pro Palomar architecture, so high availability for IMAP storage on a free build is a design question you must answer before choosing a platform. Ask any implementer how mailbox data is replicated, what happens to queued mail during a node failure and how failover is tested. Confirm whether the clustering features you need are in the edition you plan to run, using the Dovecot 2.3 to 2.4 upgrade guide if your stack uses Dovecot.

How does the deployment model affect moving mail to another platform later?

The hosting layer usually changes more easily than the data layer, so plan mailbox migration as the larger effort. Moving a stack between Docker Compose and Kubernetes can keep the same product, because Mailu documents both paths, but the storage, DNS and certificate setup still has to move. Moving to a different product means migrating mailboxes, folders, contacts, calendars, filters and DKIM keys, and each has its own export path. Ask for a written export and import plan that covers each data type, a dry run on a test domain and a rollback plan for DNS changes. A design that depends on one product's internal database or mailbox format costs more to leave later, so ask how mail is stored and whether you can export it without the vendor's tools.

How DeployOpen plans, delivers and supports a mail deployment

DeployOpen plans and implements self-hosted email inside your own cloud accounts, data centers or air-gapped networks, so the choice between Docker, Kubernetes and virtual machines is made against your infrastructure and your team's staffing. Each engagement is fixed-scope, with scope, deliverables and timelines agreed in writing before work starts. The steps below show what that covers from scoping through handover and ongoing support.

How we scope

  • The written scope names the platform option (Docker, Kubernetes or virtual machines) and the reason for it.
  • Sizing inputs are agreed up front: user count, mail volume, domains, storage growth and the RAM each component needs.
  • Deliverables, exclusions, owners and timelines are written down and agreed in writing before work starts.

How we build

  • Deploy the agreed stack inside your own cloud account, data center or air-gapped network.
  • Harden the mail stack, review the inbound TCP ports for SMTP, IMAP, POP3 and webmail, and document each exposure.
  • Run security testing against the running mail services and track each finding to a fix.

How we hand over

  • Written documentation covers the architecture, component versions, ports, backup jobs and the upgrade procedure your team will run.
  • Backup jobs for mail data, databases and configuration are set up and documented before handover.
  • Evidence for your assessors covers access controls, configuration records and logs, but independent auditors issue any attestation.

How we support

  • Ongoing support, upgrades and continuous testing are available as a retainer, scoped separately from the build.
  • Ask how upgrades cover each component, since mailcow alone runs many separate containers that each need checking.
  • Confirm in writing whether retests after changes sit inside the retainer or inside a separate scope.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.