Many of the recipes that follow require email access of some kind. It's normally possible to use a hosted service such as SendGrid, or just a gmail account. If (like me) you'd like to self-host email for your stacks, then the following recipe provides a full-stack mail server running on the docker HA swarm.
This is a companion discussion topic for the original entry at https://geek-cookbook.funkypenguin.co.nz/recipes/mail/
Thank you for the great work. Happy me after some long days my first test mailserver can send and receive some mails.
I a question maybe you have a hint for me?
My enviroment:
docker -v
Docker version 18.09.1, build 4c52b90
docker-compose -v
docker-compose version 1.23.1, build b02f1306
If I use your port section:
ports:
- target: 25
published: 25
protocol: tcp
mode: host
- target: 587
published: 587
protocol: tcp
mode: host
- target: 993
published: 993
protocol: tcp
mode: host
- target: 995
published: 995
protocol: tcp
mode: host
docker service ps --no-trunc docker-mailserver_mail
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
lmbg82ws40kxddlrgj0ltzjqx docker-mailserver_mail.1 tvial/docker-mailserver:latest@sha256:b46c0c97f24f7027519ccd68fde3fbaa54f8687c9b9afa6ca539c9bf7d34be63 server1 Ready Ready 1 second ago
n4bwhyxwh8vs2s6kooek2v4rv _ docker-mailserver_mail.1 tvial/docker-mailserver:latest@sha256:b46c0c97f24f7027519ccd68fde3fbaa54f8687c9b9afa6ca539c9bf7d34be63 server1 Shutdown Failed 2 seconds ago “starting container failed: container 20030f6216fdeb2ebad687456bd70899a0203d32542f96890b2b7e0aaeae6928: endpoint join on GW Network failed: driver failed programming external connectivity on endpoint gateway_b9216aca7814 (318f404e60c07c478672f9019b8497ee2e3da15bc7e3d5e484c5ab084eef06cb): Error starting userland proxy: listen tcp 0.0.0.0:25: bind: address already in use”
y2zvtris05fu5fdruzsii4niw _ docker-mailserver_mail.1 tvial/docker-mailserver:latest@sha256:b46c0c97f24f7027519ccd68fde3fbaa54f8687c9b9afa6ca539c9bf7d34be63 server1 Shutdown Failed 7 seconds ago “starting container failed: container cacd05bfae97777998c3613a26fbba2cfeaaf1408d050e2cff27eeb35a02cb19: endpoint join on GW Network failed: driver failed programming external connectivity on endpoint gateway_07702a69081e (7a1d2a81b5b96e632c980991cfc0f0107031fb20500c76b9a5ad5cb511f376a0): Error starting userland proxy: listen tcp 0.0.0.0:25: bind: address already in use”
b0jpkcypyp5x23eqfidf11xl4 _ docker-mailserver_mail.1 tvial/docker-mailserver:latest@sha256:b46c0c97f24f7027519ccd68fde3fbaa54f8687c9b9afa6ca539c9bf7d34be63 server1 Shutdown Failed 12 seconds ago “starting container failed: container 196e5a08b0d7a5e04b7ef7c97b9330dcca98ccf1ccff2d64812f38d9b246a18f: endpoint join on GW Network failed: driver failed programming external connectivity on endpoint gateway_798ad2f6ea14 (d6b7ec82fd368c2001e6cc8220324163f37938d7fa8765e3ddd4e0445193d542): Error starting userland proxy: listen tcp 0.0.0.0:25: bind: address already in use”
vjco9qhw2swvbadb7f7qng9t8 _ docker-mailserver_mail.1 tvial/docker-mailserver:latest@sha256:b46c0c97f24f7027519ccd68fde3fbaa54f8687c9b9afa6ca539c9bf7d34be63 server1 Shutdown Failed 18 seconds ago “starting container failed: container 5d7fd7d27ca09217ceb57fa7f056ae8affbd1d2e705f9ba5443283862ff4da71: endpoint join on GW Network failed: driver failed programming external connectivity on endpoint gateway_ccb21490840a (46924ef572e5f464c01e7f8e8ac6c85c00ce4cb62eae92cc0ecb5a02dd354829): Error starting userland proxy: listen tcp 0.0.0.0:25: bind: address already in use”
my container is not starting. I do not get any log:
docker service logs docker-mailserver_mail
If I start with the port section from hub.docker.com/r/tvial/docker-mailserver
ports:
- "25:25"
- "143:143"
- "587:587"
- "993:993"
the container is working. Any ideas?
Probably your system already has something listening on port 25… try stopping sendmail/postfix/etc, and then docker should be able to bind to the port
D
Perfect! I was not aware that the default CentOS is running an mailserver by default:
If someone else has the same problem.
To get a look:
netstat -tulpn
netstat -tulp
In my case to get rid of it:
systemctl stop postfix
yum remove postfix
Thank you.
Eddie
March 15, 2019, 12:52pm
5
Thanks for this reciepe! but i wonder if our ISP blocking port 25, how could we forward all 25 to 587 to avoid ISP … as i have use in to forward all http and https to WebSockets connection only to avoice ISP blocking port 80.
Waiting you … thanks !
Maybe I missed something, but why would I need to use host mode for the ports ?
Why not benefit from routing mesh ? Or even réplication ?
Hey @rafipiccolo , welcome the the forums!
We need host mode to avoid routing mesh in this case, since it obscures the original source IP of the incoming connection (which makes DNS-based spam filtering rather ineffective!)
D
Sounds to make like yet another time the docker userland-proxy needs to be disabled. Why didn’t they already do it by default on linux?
I’ve used this recipe for a while, but changed to this: https://mailcow.email/ It’s a docker stack that does everything. You may want to take a look at it for your cookbook. Thank you for all your work on this cookbook! I’m a fan.
That’s a good suggestion, thank you @bytebrain - I’ve heard good things about mailcow over the years!