How to run a Postfix mail server in a Docker container
operations securityAbout a year ago I moved all my websites and services to a private cloud. It runs Docker swarm mode and consists out of three machines: two without direct internet access (private nodes) and one with a public IP (public node).
During the transition two problems popped up:
- The PHP Docker containers I used didn’t ship with a
sendmail
binary, so I couldn’t send e-mails from PHP withmail()
. - One of my services ran on a private node but still needed to send e-mails. Since it had no internet access, this wasn’t possible.
After some research and some thinking I came up with a solution: running a mail relay service on my public node, which would simply receive mail from PHP containers and services on private nodes and relay those mails to my (still managed) SMTP mail-server.
Since there a some tricky parts in doing so, I wrote a guide on how you can do this yourself.
Read more...