Mail Server - Funky Penguin's Geek Cookbook


#1

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/

#2

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

  1. 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?


#3

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 :slight_smile:

D


#4

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.