赞
踩
项目网站:mailcow: dockerized – Blog
根据官方介绍,这个项目名称是mailcow,名称都是小写的。下面内容是通过AI翻译自官方文档:mailcow: dockerized documentation
mailcow: dockerized 是一个基于 Docker 的开源组件/电子邮件套件。mailcow 依赖于许多广为人知且长期使用的组件,这些组件结合起来构成了一个全方位的无忧电子邮件服务器。每个容器代表一个单一的应用程序,它们通过桥接网络连接在一起。
涉及的开源组件如下:
名称 | 说明 |
ACME | 自动生成Let’s Encrypt SSL证书 |
ClamAV | 反病毒引擎(可选) |
Dovecot | IMAP/POP 服务器,用于通过集成的全文搜索引擎“Flatcurve”检索电子邮件 |
MariaDB | 用于存储用户信息的数据库 |
Memcached | 用于缓存SOgo webmail相关数据 |
Netfilter | 类似Fail2ban的工具,由 @mkuron 提供 |
Nginx | 提供web服务 |
Olefy | 对Office文档进行病毒、宏等分析,主要和Rspamd搭配使用。 |
PHP | 提供WEB相关运行环境 |
Postfix | 提供MTA服务 |
Redis | 用于存储反垃圾、DKIM key相关信息。 |
Rspamd | 带有垃圾邮件自动学习功能的垃圾邮件过滤器 |
SOGo | 一组提供CalDAV、CardDAV、ActiveSync服务的套件。 |
Solr | (已弃用)(可选)为IMAP连接提供全文搜索功能,以便快速搜索电子邮件 |
Unbound | 集成的DNS服务器,用于验证DNSSEC等 |
Watchdog | 用于mailcow内容器状态的基本监控 |
但是,mailcow的核心是其图形化Web界面,即mailcow UI。它几乎提供了所有设置的地方,并允许用户通过几次点击轻松创建新的域名和电子邮件地址。
它也可以轻松完成其他或更复杂的任务:
mailcow的数据(如邮件数据、用户数据等)存储在Docker的卷中,需要注意备份。涉及的卷名称如下:
参考:Prepare your system – mailcow: dockerized documentation
官方文档说的很详细,这里仅作概要说明。
资源项 | 配置要求 |
CPU | 1GHz |
内存 | 最小6GB + 1GB swap |
磁盘 | 最小20GB,邮件数据存储空间另算 |
CPU架构 | x86_64, ARM64 |
仅支持运行在全虚拟化(如KVM、ESX,、Hyper-V 等)的服务器上,不支持半虚拟化环境(如OpenVZ、LXC等)。
注:建议查询官方文档获取最新的兼容测试情况。
操作系统版本 | 兼容情况 |
Debian 11, 12 | 完全兼容 |
Ubuntu 20.04 – 24.04 | 完全兼容 |
Alma Linux 8 | 完全兼容 |
Rocky Linux 9 | 完全兼容 |
Alpine since 3.17 | 兼容,但需要做一些手动调整 |
本文采用Rocky Linux 9作为安装演示。
请参考官方文档:Prepare your system – mailcow: dockerized documentation
需要安装 Docker(版本要求 >= 20.10.2)和 Docker Compose(版本要求 >= 2.0)。
(1)安装yum源
cd /etc/yum.repos.d/
# 采用阿里云的yum源
wget http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
(2)安装docker
yum -y install docker-ce docker-ce-cli containerd.io
(3)查看docker版本
- [root@mail ~]# docker -v
-
- Docker version 27.0.3, build 7d4bcd8
(4)设置docker开机自启动
systemctl enable --now docker
(5)配置docker镜像加速站点
注意:目前国内的镜像加速站点在2024年之后基本上不好使了,这里给几个目前(2024年7月初)可用的加速站点。国内大概率会卡在这一步。
vim /etc/docker/daemon.json
加入如下内容:
- {
- "registry-mirrors": [
- "https://dockerhub.icu",
- "https://docker.anyhub.us.kg",
- "https://hub.uuuadc.top",
- "https://dockerhub.jobcher.com",
- "https://docker.ckyl.me",
- "https://docker.awsl9527.cn"
- ]
- }
重启docker生效:
- systemctl daemon-reload
- systemctl restart docker
- $ su
-
- # umask
-
- 0022 # <- Verify it is 0022
-
- # cd /opt
-
- # git clone https://github.com/mailcow/mailcow-dockerized
-
- # cd mailcow-dockerized
注意:如果访问不到github,需要考虑使用梯子。mailcow-dockerized目录非常重要,这里有所有配置文件信息,一定要保存好。
(1)生成配置文件
- [root@mail mailcow-dockerized]# ./generate_config.sh
- Found Docker Compose Plugin (native).
- Setting the DOCKER_COMPOSE_VERSION Variable to native
- Notice: You´ll have to update this Compose Version via your Package Manager manually!
- Press enter to confirm the detected value '[value]' where applicable or enter a custom value.
- Mail server hostname (FQDN) - this is not your mail domain, but your mail servers hostname: mail.mailabc.cn
- Timezone [Asia/Shanghai]:
- Which branch of mailcow do you want to use?
-
- Available Branches:
- - master branch (stable updates) | default, recommended [1]
- - nightly branch (unstable updates, testing) | not-production ready [2]
- Choose the Branch with it´s number [1/2] 1
- 已经位于 'master'
- 您的分支与上游分支 'origin/master' 一致。
- Generating snake-oil certificate...
- .........
- -----
- Copying snake-oil certificate...
- Detecting if your IP is listed on Spamhaus Bad ASN List...
- Check completed! Your IP is clean
注意:上述采用mail.mailabc.cn作为访问域名,需要根据实际情况修改。
脚本最终生成mailcow.conf、docker-compose.yml以及各模块的相关配置,一定要保存好。
(2)执行命令拉取镜像
注意:这里根据网络情况,可能会拉取很慢,也可能会不成功。如果拉取不成功,需要检查docker镜像站点是否可用。命令需要在mailcow-dockerized目录下执行(主要是用来找配置文件)。
docker compose pull
拉取成功后,大概可以看到下面这些镜像:
- [root@mail mailcow-dockerized]# docker images
- REPOSITORY TAG IMAGE ID CREATED SIZE
- memcached alpine 936dbfa3fd1a 8 days ago 15.7MB
- mailcow/phpfpm 1.88 f9d025710983 9 days ago 301MB
- mailcow/dovecot 1.30 2aca708281e0 10 days ago 251MB
- mailcow/solr 1.8.3 a77fb6cd923e 10 days ago 454MB
- mailcow/postfix 1.75 d13755c00185 11 days ago 335MB
- mailcow/dockerapi 2.08 adc1446be9a4 13 days ago 166MB
- mailcow/olefy 1.13 6572de3dccbb 13 days ago 112MB
- mailcow/watchdog 2.03 c801c70f93a6 13 days ago 117MB
- mailcow/acme 1.88 a97424882d9c 13 days ago 146MB
- mailcow/netfilter 1.59 59b514e53b6d 13 days ago 110MB
- mailcow/rspamd 1.96 f3ddc7d4a34a 13 days ago 184MB
- nginx mainline-alpine 099a2d701db1 2 weeks ago 43.2MB
- mariadb 10.5 8d27db214bfa 3 weeks ago 394MB
- mailcow/clamd 1.66 5b6dfc3668d8 4 weeks ago 78.8MB
- mailcow/unbound 1.22 8ccf6655d8aa 4 weeks ago 27.7MB
- mcuadros/ofelia latest 05600fa3b007 5 weeks ago 23MB
- redis 7-alpine 38a44d796822 6 weeks ago 40.7MB
- mailcow/sogo 1.123 f41cfca2cd8b 4 months ago 336MB
- robbertkl/ipv6nat latest b789d3355d66 2 years ago 18MB
(3)通过docker compose 部署
注意:docker compose 采用生成的配置docker-compose.yml 来部署容器。命令需要在mailcow-dockerized目录下执行(主要是用来找配置文件)。
docker compose up -d
如果一切顺利,则容器会自动启动完成,输出大致如下:
- [root@mail mailcow-dockerized]# docker compose up -d
- [+] Running 20/20
- ✔ Network mailcowdockerized_mailcow-network Created 0.1s
- ✔ Container mailcowdockerized-netfilter-mailcow-1 Started 0.4s
- ✔ Container mailcowdockerized-olefy-mailcow-1 Started 0.8s
- ✔ Container mailcowdockerized-sogo-mailcow-1 Started 0.9s
- ✔ Container mailcowdockerized-memcached-mailcow-1 Started 0.6s
- ✔ Container mailcowdockerized-dockerapi-mailcow-1 Started 0.8s
- ✔ Container mailcowdockerized-unbound-mailcow-1 Healthy 43.2s
- ✔ Container mailcowdockerized-clamd-mailcow-1 Started 43.4s
- ✔ Container mailcowdockerized-mysql-mailcow-1 Started 1.0s
- ✔ Container mailcowdockerized-solr-mailcow-1 Started 0.8s
- ✔ Container mailcowdockerized-redis-mailcow-1 Started 0.9s
- ✔ Container mailcowdockerized-dovecot-mailcow-1 Started 1.4s
- ✔ Container mailcowdockerized-postfix-mailcow-1 Started 43.8s
- ✔ Container mailcowdockerized-php-fpm-mailcow-1 Started 1.1s
- ✔ Container mailcowdockerized-rspamd-mailcow-1 Started 1.6s
- ✔ Container mailcowdockerized-ofelia-mailcow-1 Started 1.7s
- ✔ Container mailcowdockerized-nginx-mailcow-1 Started 1.4s
- ✔ Container mailcowdockerized-acme-mailcow-1 Started 43.7s
- ✔ Container mailcowdockerized-watchdog-mailcow-1 Started 44.0s
- ✔ Container mailcowdockerized-ipv6nat-mailcow-1 Started 44.0s
注意:在我安装过程中,经常卡在mailcowdockerized-unbound-mailcow-1这个容器,经过分析发现这里对”1.1.1.1″ “8.8.8.8” “9.9.9.9”三个dns做ping检查,并且通过本机的dns检查”mailcow.email” “github.com” “hub.docker.com”这三个域名的解析情况。如果监测不通过,这个容器的状态就会变为不健康状态,导致后续依赖的容器启动异常。如果判断是这种问题,可以考虑检查本地网络环境是否对上述三个dns做了禁ping,可以考虑更换网络环境或者禁止检查dns状态。
启动完成后,检查容器状态如下:
- [root@mail mailcow-dockerized]# docker ps -a
- CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
- 2ce2db0778fa robbertkl/ipv6nat "/docker-ipv6nat-com…" 6 minutes ago Up 5 minutes mailcowdockerized-ipv6nat-mailcow-1
- a19056491f2f mailcow/watchdog:2.03 "/bin/sh -c /watchdo…" 6 minutes ago Up 5 minutes mailcowdockerized-watchdog-mailcow-1
- 89fa369acc2d mailcow/acme:1.88 "/sbin/tini -g -- /s…" 6 minutes ago Up 5 minutes mailcowdockerized-acme-mailcow-1
- e4eb3960e7ba nginx:mainline-alpine "/docker-entrypoint.…" 6 minutes ago Up 6 minutes 0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp mailcowdockerized-nginx-mailcow-1
- ffbb6b64e962 mcuadros/ofelia:latest "/usr/bin/ofelia dae…" 6 minutes ago Up 6 minutes mailcowdockerized-ofelia-mailcow-1
- b56c8483c4eb mailcow/rspamd:1.96 "/docker-entrypoint.…" 6 minutes ago Up 6 minutes mailcowdockerized-rspamd-mailcow-1
- 30ac2cb92b0e mailcow/phpfpm:1.88 "/docker-entrypoint.…" 6 minutes ago Up 6 minutes 9000/tcp mailcowdockerized-php-fpm-mailcow-1
- c3040b9328d0 mailcow/dovecot:1.30 "/docker-entrypoint.…" 6 minutes ago Up 6 minutes 0.0.0.0:110->110/tcp, :::110->110/tcp, 0.0.0.0:143->143/tcp, :::143->143/tcp, 0.0.0.0:993->993/tcp, :::993->993/tcp, 0.0.0.0:995->995/tcp, :::995->995/tcp, 0.0.0.0:4190->4190/tcp, :::4190->4190/tcp, 127.0.0.1:19991->12345/tcp mailcowdockerized-dovecot-mailcow-1
- 50202b3fa87b mailcow/postfix:1.75 "/docker-entrypoint.…" 6 minutes ago Up 5 minutes 0.0.0.0:25->25/tcp, :::25->25/tcp, 0.0.0.0:465->465/tcp, :::465->465/tcp, 0.0.0.0:587->587/tcp, :::587->587/tcp, 588/tcp mailcowdockerized-postfix-mailcow-1
- 696102aefc50 redis:7-alpine "docker-entrypoint.s…" 6 minutes ago Up 6 minutes 127.0.0.1:7654->6379/tcp mailcowdockerized-redis-mailcow-1
- aec5fe15f87a mariadb:10.5 "docker-entrypoint.s…" 6 minutes ago Up 6 minutes 127.0.0.1:13306->3306/tcp mailcowdockerized-mysql-mailcow-1
- b2de735b4c1a mailcow/solr:1.8.3 "docker-entrypoint.s…" 6 minutes ago Up 6 minutes 127.0.0.1:18983->8983/tcp mailcowdockerized-solr-mailcow-1
- 18e99d4aaaa0 mailcow/clamd:1.66 "/sbin/tini -g -- /c…" 6 minutes ago Up 5 minutes (healthy) mailcowdockerized-clamd-mailcow-1
- 48956f071997 mailcow/olefy:1.13 "python3 -u /app/ole…" 6 minutes ago Up 6 minutes mailcowdockerized-olefy-mailcow-1
- e97d663039ae mailcow/dockerapi:2.08 "/bin/sh /app/docker…" 6 minutes ago Up 6 minutes mailcowdockerized-dockerapi-mailcow-1
- 356663b16ba2 mailcow/netfilter:1.59 "/bin/sh -c /app/doc…" 6 minutes ago Up 5 minutes mailcowdockerized-netfilter-mailcow-1
- 552b90c2f6b6 mailcow/unbound:1.22 "/docker-entrypoint.…" 6 minutes ago Up 6 minutes (healthy) 53/tcp, 53/udp mailcowdockerized-unbound-mailcow-1
- b9b40462fc5b memcached:alpine "docker-entrypoint.s…" 6 minutes ago Up 6 minutes 11211/tcp mailcowdockerized-memcached-mailcow-1
- a11204b27fa6 mailcow/sogo:1.123 "/docker-entrypoint.…" 6 minutes ago Up 6 minutes mailcowdockerized-sogo-mailcow-1
- [root@mail mailcow-dockerized]#
至此,安装完成。
可以通过IP或者域名(前提是做了dns解析)访问,正常显示界面如下:
使用默认的管理员账号和密码登录(账号:admin,密码:moohoo),登录之后需要立即修改密码:
在这里可以设置域名、账号等等参数。
为了便于测试,我创建了一个邮件账号admin@mailabc.cn,登录webmail界面(入口是:https://domain/SOGo/)做一下邮件发送测试:
webmail登录界面:
登录之后界面如图:
其他功能,后续我们再做测试和介绍。
文章来源:使用Docker部署mailcow开源邮件系统详细过程 | MailABC邮件知识百科
更多内容,可以关注mailabc公众号。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。