Hi Wietse,

Thank you for your answer.

The docker containers are running Debian 9.3 and the postfix package from the official Debian repository (Version: 3.1.6-0+deb9u1).

As you can see below the source code still contains calls to gethostbyname():

postfix-3.1.6~ fgrep gethostbyname . -R -n
./proto/stop:603:gethostbyname
./auxiliary/name-addr-test/gethostbyname.c:2: * gethostbyname tester. compile with: ./auxiliary/name-addr-test/gethostbyname.c:4: * cc -o gethostbyname gethostbyname.c (SunOS 4.x) ./auxiliary/name-addr-test/gethostbyname.c:6: * cc -o gethostbyname gethostbyname.c -lnsl (SunOS 5.x) ./auxiliary/name-addr-test/gethostbyname.c:8: * run as: gethostbyname hostname ./auxiliary/name-addr-test/gethostbyname.c:29: if (hp = gethostbyname(argv[1])) { ./src/util/myaddrinfo.c:350: if ((hp = gethostbyname(hostname)) == 0)
./src/util/find_inet.c:69:      if ((hp = gethostbyname(host)) == 0)
./src/smtp/smtp_addr.c:25:/*    getnameinfo() or gethostbyname().
./src/local/biff_notify.c:69: if ((hp = gethostbyname("localhost")) == 0) {
./HISTORY:103:  gethostbyname() to look up its own machine name.  Sites
./HISTORY:6720: hostname to "unknown". Some gethostbyname() implementations ./HISTORY:13578: adding gethostbyname() calls that cause maildir delivery ./HISTORY:22047: adding code that calls gethostbyname() to determine the

Regarding the docker network, I followed the recommendations of the official website and I'm using a user-defined network, which works with no issue. I can correctly resolve the containers when in Debian by just using their name:

~ cat /etc/resolv.conf
search openstacklocal
nameserver 127.0.0.11
options ndots:0

~ cat /etc/hosts
127.0.0.1       localhost
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.20.0.4      postfix

~ ping dovecot -c1
PING dovecot (172.20.0.5): 56 data bytes
64 bytes from 172.20.0.5: icmp_seq=0 ttl=64 time=0.165 ms
--- dovecot ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max/stddev = 0.165/0.165/0.165/0.000 ms

~ nslookup dovecot
Server:         127.0.0.11
Address:        127.0.0.11#53

Non-authoritative answer:
Name:   dovecot
Address: 172.20.0.5

As said before, using the hostname and not the IP address of the dovecot container in the "virtual_transport" and "mailbox_transport" works:

# main.cf
...
mailbox_transport = lmtp:inet:dovecot:24
virtual_transport = lmtp:inet:dovecot:24
...

The issue here is the "smtpd_sasl_path " parameter.
When I set it this way, it doesn't resolve the hostname:

smtpd_sasl_path = inet:[dovecot]:12345

(I tried both with and without [])

But when I directly put the IP address:

smtpd_sasl_path = inet:[172.20.0.5]:12345

or add an hosts entry in /var/spool/postfix/etc/hosts:

172.20.0.5 dovecot

Everything works as expected

Kr,
Lorenzo

---
LORENZO BERNARDI

On 2017-12-27 00:51, wie...@porcupine.org wrote:

Lorenzo Bernardi:

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

The getaddrinfo() SYSTEM LIBRARY routine, given hostname 'dovecot',
found no IP address. Postfix does not use gethostbyname() except
on systems that are more than 10 years old.

Everything also works correctly if I add the following entry in
/var/spool/postfix/etc/hosts:
172.20.0.5 dovecot

There should be no need to do that.

According to Docker documentation, "If you want containers to be
able to resolve IP addresses by container name, you should use
user-defined networks instead [of using the default bridge network]".

docs.docker.com/engine/userguide/networking/#the-default-bridge-network

Wietse

Reply via email to