docker-mailman icon indicating copy to clipboard operation
docker-mailman copied to clipboard

"MM_HOSTNAME" auto-discovery fails when core is connected to multiple networks

Open Nebukadneza opened this issue 6 years ago • 2 comments

When connecting the mailman-core container to multiple networks — for example if the docker host uses one central database-container for multiple services — the autodiscovery of the MM_HOSTNAME variable here: https://github.com/maxking/docker-mailman/blob/master/core/docker-entrypoint.sh#L33 fails. In this case, hostname -i will return 172.19.199.2 <ip it got in the db network>, or similar depending on your configuration.

While this is workaroundable by setting a MM_HOSTNAME env manually, it’d be nice if multiple IPs could be detected and handled correctly ….

Nebukadneza avatar Dec 14 '18 19:12 Nebukadneza

So, there is an interesting problem with having to use multiple IPs with Mailman Core.

Mailman Core listens for LMTP connections on $MM_HOSTNAME and it also uses the same value to generate alias_maps for MTA to contact Mailman Core at. It we choose a random IP from multiple outputs of hostname -i or use 0.0.0.0 (to listen on all available interfaces), MTA alias_maps will use those addresses (one of available interfaces/0.0.0.0) and they won't be able to reach Core.

I would like this hostname -i thing to actually go away completely and instead forward Ports from the container to host and then we can just use localhost everywhere.

maxking avatar Dec 21 '18 19:12 maxking

Ran into this issue when adding a second docker network to the mailman-core container:

services:
  mailman-core:
[...]
    networks:
      mailman:
        ipv4_address: 172.19.199.2
      mailserver:   <========= Added

The second network is the one of the MTA (Postfix), so I could easily enable relaying outbound mail by just allowing relaying from this network in Postfix.

As soon as adding the second network, the REST API wasn't available anymore from mailman-web, although I could ping mailman-core.

I found out that adding the network changes the gunicorn log in mailman-core from: [2020-12-28 19:06:36 +0000] [40] [INFO] Starting gunicorn 19.9.0 [2020-12-28 19:06:36 +0000] [40] [INFO] Listening at: http://172.19.199.2:8001 (40)

to: 2020-12-30 16:59:43 +0000] [33] [INFO] Starting gunicorn 19.9.0 [2020-12-30 16:59:43 +0000] [33] [ERROR] Retrying in 1 second.

Setting MM_HOSTNAME=172.19.199.2 for mailman-core fixes the issue for me.

sierracc avatar Dec 30 '20 17:12 sierracc

This issue has not been updated for more than 1year

github-actions[bot] avatar Nov 06 '22 22:11 github-actions[bot]