Simple mail server with docker
A few months ago, I started a migration of an old Linux server to a MacMini, running Debian Jessie and all its services in Docker containers.
It was really easy for DNS or Web Server. But a mail server is really more complicated:
- it uses a bunch of daemons (imap, smtp)
- it also needs additional services (anti-spam, anti-virus...)
- configuration can be tricky
- security is very important
Why don't you go with Google?
I'm running my mail server at home since 2005, and it helped me a lot to understand how internet works :
- mail protocols (smtp, imap)
- security, open relay and firewalls
- dns, spf
- antispam
The other reason is that I have 500+ aliases on my personal account, one for each web site I have an account, and I really want to keep this feature, which is currently limited to 30 aliases with Google Apps.
Do not reinvent the wheel
I had a look to some docker images, but most of them where more complicated than I expected, and also using *SQL databases.
I wanted something:
- simple to install
- versionable, only based on config files that can be pushed into my git repository
- easy to deploy using a single command line
Here comes docker-mailserver
I released tvial/docker-mailserver
on the docker registry.
I also released the source code on Github.
I personally use this image every day on a multi-account/domain/user server.
How does it works?
To be simple, this image is based on convention over configuration concept. Of course, if you need something more specific, it's also possible.
The mains files are:
postfix/accounts.cf
to manage users and passwordspostfix/virtual
to manage aliases and forwards
And that's it.
Start you container using docker
or docker-compose
and you have a running mail server with:
- postfix
- courier-imap
- amavis
- clamav with automatic updates
- spamassassin
- ready for SSL and LetsEncrypt
- opendkim and opendmarc
One more thing?
Yep. You can also:
- add specific spamassassin rules into
spamassassin/rules.cf
- generate a self-signed certificate using a dedicated tool (which can be tricky...)
You're welcome
Please have a look to the detailed README
on Github.
You're also welcome if you want to improve this docker image. Just open an issue, we'll talk about your idea, I'll help you and merge.
Oh yeah! #docker mail server just reached 200 #github stars! Thanks you guys and feel free to contribute - https://t.co/bnZM0CkL0i
— Thomas VIAL (@tvial) 24 Février 2016
And big thanks to @docker for this Tweet:
From this week's #DockerWeekly @tvial explains how to create a simple mail server with @Docker: http://t.co/n1of1KKNKM
— Docker (@docker) September 12, 2015