Mailcow (mailcow: dockerized) packages a complete mail server into Docker containers: Postfix and Dovecot for mail, Rspamd for spam filtering, ClamAV, SOGo for webmail, calendar and contacts, and a web admin interface that is genuinely pleasant to use. It is one of the quickest ways to run your own business email. This guide shows how to install Mailcow on Ubuntu or AlmaLinux, with the requirements, ports and DNS records you need to get right first. To see how it compares with Zimbra and Carbonio, read Self-Hosted Email on Zimbra, Carbonio or Mailcow vs M365 and Google.
The details below follow the official Mailcow documentation as of November 2026. Check the documentation for changes before installing on a production server.
Mailcow System Requirements
| Item | Requirement |
|---|---|
| CPU | 1 GHz or better, x86_64 or ARM64 |
| RAM | 6 GiB minimum plus 1 GiB of swap |
| Disk | 20 GiB without mail, plus space for mailboxes |
| Virtualisation | KVM, ESX and Hyper-V are supported. OpenVZ, Virtuozzo and LXC are not supported. Do not install on a NAS |
| Operating system | Debian 11 to 13, Ubuntu 22.04 or newer, AlmaLinux 8 and 9, Rocky Linux 9 (Alpine from 3.19 has limited support). Others are untested |
| Docker | Docker 24.0.0 or newer and Docker Compose 2.0 or newer |
The OpenVZ and LXC restriction matters if you buy a VPS: choose a KVM VPS. See KVM vs OpenVZ vs LXC vs Docker for why.
Ports You Need
Mailcow must be reachable on these incoming ports:
| Ports | Service |
|---|---|
| 25, 465, 587 | SMTP, SMTPS, submission |
| 143, 993 | IMAP and IMAPS |
| 110, 995 | POP3 and POP3S |
| 4190 | Sieve |
| 80, 443 | HTTP and HTTPS (web admin, webmail, certificates) |
Before installing, check that nothing else is using them:
ss -tlpn | grep -E -w '25|80|110|143|443|465|587|993|995|4190'
Stop and disable any existing Postfix, Dovecot, Apache or Nginx. The documentation also warns against running firewalld or ufw on the host in the usual way, because Docker manages its own rules and they interfere. Use the DOCKER-USER chain or a firewall in front of the server (a network firewall or your cloud provider’s security groups). For firewall concepts, see our Linux server hardening guide.
Outbound access is needed to GitHub, Docker Hub and several update and signature services.
Step 1: Set the Host Name and Prepare DNS
Choose a fully qualified host name such as mail.example.com and set it:
hostnamectl set-hostname mail.example.com
Create these DNS records for each mail domain (replace the example values):
| Record | Example value |
|---|---|
| A | mail points to your server’s IPv4 address (also AAAA for IPv6) |
| MX | example.com MX 10 mail.example.com. |
| CNAME | autodiscover and autoconfig pointing to mail.example.com. |
| SPF (TXT) | v=spf1 mx a -all |
| DMARC (TXT) | _dmarc with v=DMARC1; p=quarantine; rua=mailto:dmarc@example.com (start with p=none if unsure) |
| PTR | Reverse DNS of the IP must match mail.example.com |
DKIM is created later in the Mailcow interface. Optional SRV records for autodiscovery are listed in the advanced DNS page of the documentation. The records are explained in depth in How to Configure SPF, DKIM and DMARC and Reverse DNS (PTR) and deliverability.
Step 2: Install Docker and Packages
On Ubuntu or Debian:
apt update && apt install -y git openssl curl gawk coreutils grep jq
curl -sSL https://get.docker.com/ | CHANNEL=stable sh
systemctl enable --now docker
On AlmaLinux or Rocky Linux, install Docker from Docker’s official repository (dnf config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo then dnf install docker-ce docker-ce-cli containerd.io docker-compose-plugin) and install git, openssl, curl, gawk, jq with dnf. Confirm versions:
docker --version
docker compose version
On RHEL-family systems, be aware that SELinux and firewalld are on by default. Follow the Mailcow notes for your distribution rather than disabling security features blindly.
Step 3: Download Mailcow
Use the directory the documentation recommends, and set a safe umask first:
umask 0022
cd /opt
git clone https://github.com/mailcow/mailcow-dockerized
cd mailcow-dockerized
Step 4: Generate the Configuration
./generate_config.sh
The script asks for the mail host name (use mail.example.com), the time zone and the branch (use the stable branch for production). It writes mailcow.conf. Review it, and edit only if you understand the options:
nano mailcow.conf
Common settings are HTTP_PORT and HTTPS_PORT if you place a reverse proxy in front, and SKIP_LETS_ENCRYPT if you provide your own certificates. If your host has no IPv6, follow the documentation’s note on disabling IPv6 for Mailcow.
Step 5: Install Mailcow and Start It
docker compose pull
docker compose up -d
The first start downloads many images and can take several minutes. Mailcow requests a Let’s Encrypt certificate for the host name automatically once DNS resolves to the server and ports 80 and 443 are reachable. Watch for problems with:
docker compose ps
docker compose logs -f --tail=50 acme-mailcow
Step 6: Log In and Change the Default Password Immediately
Open https://mail.example.com/admin. The initial credentials in the documentation are the user admin with the password moohoo. Change this password straight away from the user menu, and consider enabling two-factor authentication for the admin account. Any server left on a documented default password will be found by bots quickly.
Step 7: Add Your Domain, a Mailbox and DKIM
- Go to Configuration » Mail Setup » Domains and add your domain
- Under Mailboxes, create your first mailbox and set a quota
- Open the domain’s DKIM settings (in the same area or under ARC/DKIM keys), generate a key and copy the TXT record to DNS (
dkim._domainkeywithv=DKIM1; k=rsa; ...) - Visit
https://mail.example.com/SOGoand sign in to use webmail, calendar and contacts
Menu names can differ slightly between Mailcow versions. The next tutorial, Mailcow Tutorial: Domains, Mailboxes, Aliases, Quotas and SOGo, goes through administration in detail.
Step 8: Test Before You Trust It
- Send mail to and from Gmail or Outlook, and check the headers for
SPF,DKIMandDMARCpass - Test with an online mail-test tool for a score and blacklist check
- Check TLS on ports 465 and 993
- Confirm the reverse DNS resolves to the right host name
- New IP address? Send slowly at first; see IP and domain warm-up plan
Troubleshooting Common Install Problems
| Problem | Likely cause |
|---|---|
| Containers restart or fail | Not enough RAM, or unsupported virtualisation such as LXC |
| Port already in use | Another mail or web server is running. Stop it |
| No Let’s Encrypt certificate | DNS does not point to the server yet, or port 80 is blocked |
| Cannot reach outside hosts | Outbound firewall, or MTU mismatch. The docs describe setting a Docker network MTU if your provider uses a value other than 1500 |
| Mail rejected by others | Missing PTR, SPF or DKIM, or a blacklisted IP |
| Port 25 blocked | Many cloud providers block it by default. Ask them to unblock it |
Keep It Safe and Running
Plan updates and backups straight away. See Mailcow Backup, Update and Migration to a New Server. A mail server is a high-value target, so keep the host patched and restricted, and use Fail2Ban or the built-in Netfilter protection that Mailcow includes.
Frequently Asked Questions
Can I install Mailcow on a shared hosting account?
No. Mailcow needs a KVM VPS or dedicated server with root access and Docker. Container-based VPS platforms such as OpenVZ or LXC are not supported.
How much RAM does Mailcow need?
The documented minimum is 6 GiB of RAM plus 1 GiB of swap. More is better if you use ClamAV and many mailboxes.
What is the default Mailcow admin password?
The documentation lists the user admin and password moohoo for the first login. Change it immediately.
Can I run Mailcow behind a reverse proxy?
Yes, Mailcow documents reverse proxy setups. Change the HTTP and HTTPS ports in mailcow.conf and pass the traffic through your proxy.
Do I need Docker Compose v1 or v2?
Use the docker compose plugin (v2). Docker Compose 2.0 or newer is required.
