I've build a Docker based "Perfect server" clone of this tutorial, but more up-to-date and I succeeded at sending and receiving emails locally via the Roundcube webmail application towards external email accounts without using external relays. However, I cannot figure out why connections between mail clients and the mailserver continiously fail.
First of all, my docker-compose.yml file globally contains:
version: '3.0'
services:
mailserver:
container_name: mailserver
image: mailserver:latest
build: .
restart: on-failure
hostname: ${HOSTNAME}
domainname: ${DOMAIN}
ports:
- 80:80
- 25:25
- 143:143
- 465:465
- 587:587
- 993:993
- 995:995
environment:
- HOSTNAME=mail
- DOMAIN=localhost
- MYSQL_HOST=localhost
- MYSQL_PASSWORD=password
networks:
- default
networks:
default-network:
driver: bridge
Recently, I build another image containing a standalone mailserver existing out of Postfix, Dovecot, Roundcube, PhpMyAdmin and Apache since I wanted to test differences about why those connections between the mailserver and mail-clients fail.
For that, I pretty much installed all dependencies, and changed some Postfix values like:
postconf -e myhostname="${HOSTNAME}"
postconf -e mydomain="${DOMAIN}"
postconf -e mydestination="${HOSTNAME}, localhost.${DOMAIN}, localhost, ${DOMAIN}"
postconf -e mynetworks="127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128"
For the last image, I've just followed this tutorial to the point where it should connect Thunderbird to the mailserver.
NOTE: The reason I'm using (and testing with) ports 143 and 25, but will not use them in final form.
But the same thing as the "Perfect server" -image occurred, which is that the client couldn't connect to the mailserver.
Meanwhile while building that image, I launched a virtual machine (same domain, ip address and network) without using containers (Debian 10) by following the exact same tutorial (Perfect server). And in the end, I succeeded the connection with Outlook/Thunderbird (again over the same ports).
So I came to the conclusion that I'm missing something that solves the issue about the reason why Docker containers prevent/block those connections even when ports are open and DNS records are set.
Question: what am I doing wrong/why do mail clients fail connections towards the mailserver while being inside a Docker container?
Perfect server based Docker image for reference: https://github.com/jerob/docker-ispconfig