Hi all,
I'm currently trying to dockerize my mail server environment and
encountered a strange issue on which I spent some time to debug.
I have several docker containers running different components:
- postfix (172.20.0.4): postfix 3.1.6-0+deb9u1
- dovecot (172.20.0.5): dovecot 1:2.2.27-3+deb9u1
- antispam (172.20.0.7): amavisd-new 1:2.10.1-4 & spamassassin
3.4.1-6+deb9u1
I setup dovecot to handle SASL and listen on port 12345.
When I use the hostname in postfix configuration, I receive the
following error:
postfix/smtpd[141]: fatal: host/service dovecot/12345 not found: No
address associated with hostname
When using the IP address of the dovecot container, I don't have that
issue and everything runs as expected.
Everything also works correctly if I add the following entry in
/var/spool/postfix/etc/hosts:
172.20.0.5 dovecot
It looks like postfix is not correctly resolving the hostname from the
"smtpd_sasl_path" parameter.
FYI: I connect to the dovecot container using its hostname in the
"mailbox_transport" and "virtual_transport" and those are correctly
resolved, thanks to the "lmtp_host_lookup = dns" parameter.
FYI2: I copied the content of the /etc/resolv.conf file from the postfix
container to the /var/spool/postfix/etc/ in the same container in order
to make the postfix dns resolution work.
After some digging in the source code, I noticed the error should come
from util/inet_connect.c (line 98):
if ((aierr = hostname_to_sockaddr(host, port, SOCK_STREAM, &res0)) != 0)
msg_fatal("host/service %s/%s not found: %s",
host, port, MAI_STRERROR(aierr));
This calls hostname_to_sockaddr which uses "gethostbyname" in
util/myaddrinfo.c (line 350):
/*
* Look up the IPv4 address list.
*/
if ((hp = gethostbyname(hostname)) == 0)
return (h_errno == TRY_AGAIN ? EAI_AGAIN : EAI_NODATA);
if (hp->h_addrtype != AF_INET
|| hp->h_length != sizeof(template.sin.sin_addr))
return (EAI_NODATA);
I was wondering if the hostname lookup was handled differently for the
other parameters, and if it was possible to either fix that behavior or
add an option to do a proper dns lookup and thus correctly resolve the
hostname in the "smtpd_sasl_path" parameter.
Below the relevant part of my postfix main.cf file.
I can provide more logging if needed.
Thanks in advance for your help!
Kind regards,
Lorenzo Bernardi
#### main.cf ####
...
lmtp_host_lookup = dns
...
mailbox_transport = lmtp:inet:dovecot:24
...
smtp_host_lookup = dns
...
smtpd_sasl_path = inet:[dovecot]:12345
smtpd_sasl_type = dovecot
...
virtual_transport = lmtp:inet:dovecot:24
...
#### /main.cf ####