docker-mailserver: bug report: bad hostname or network address: 127.0.0.1:10025
📝 Preliminary Checks
- I tried searching for an existing issue and followed the debugging docs advice, but still need assistance.
👀 What Happened?
postfix does not start, because of an error
👟 Reproduction Steps
I just downloaded the compose.yaml and mailserver.env, changed anything what was needed (hostname etc.) and started the container. (docker compose up)
🐋 DMS Version
v13.3.1
💻 Operating System and Architecture
Debian 12 as XEN Domu
⚙️ Container configuration files
services:
mailserver:
image: ghcr.io/docker-mailserver/docker-mailserver:latest
container_name: mailserver
# Provide the FQDN of your mail server here (Your DNS MX record should point to this value)
hostname: mail.example.com
env_file: mailserver.env
# More information about the mail-server ports:
# https://docker-mailserver.github.io/docker-mailserver/latest/config/security/understanding-the-ports/
ports:
- "25:25" # SMTP (explicit TLS => STARTTLS, Authentication is DISABLED => use port 465/587 instead)
- "143:143" # IMAP4 (explicit TLS => STARTTLS)
- "465:465" # ESMTP (implicit TLS)
- "587:587" # ESMTP (explicit TLS => STARTTLS)
- "993:993" # IMAP4 (implicit TLS)
volumes:
- ./docker-data/dms/mail-data/:/var/mail/
- ./docker-data/dms/mail-state/:/var/mail-state/
- ./docker-data/dms/mail-logs/:/var/log/mail/
- ./docker-data/dms/config/:/tmp/docker-mailserver/
- /etc/localtime:/etc/localtime:ro
restart: always
stop_grace_period: 1m
# Uncomment if using `ENABLE_FAIL2BAN=1`:
# cap_add:
# - NET_ADMIN
healthcheck:
test: "ss --listening --tcp | grep -P 'LISTEN.+:smtp' || exit 1"
timeout: 3s
retries: 0
📜 Relevant log output
mail postfix/master[1037]: fatal: /etc/postfix/master.cf: line 93: bad hostname or network address: 127.0.0.1:10025
My network on the host:
docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255
inet6 fd00:4f8:162:138f::1 prefixlen 64 scopeid 0x0<global>
inet6 fe80::1 prefixlen 64 scopeid 0x20<link>
ether 02:42:a4:b5:be:f9 txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
enX0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::216:3eff:fe56:4155 prefixlen 64 scopeid 0x20<link>
inet6 2001:db8::2 prefixlen 128 scopeid 0x0<global>
ether 00:16:3e:56:41:55 txqueuelen 1000 (Ethernet)
RX packets 34964 bytes 2342822 (2.2 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 7320 bytes 1703624 (1.6 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
enX1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.4.100 netmask 255.255.255.0 broadcast 192.168.4.255
inet6 fe80::216:3eff:fe2e:2087 prefixlen 64 scopeid 0x20<link>
ether 00:16:3e:2e:20:87 txqueuelen 1000 (Ethernet)
RX packets 43 bytes 27862 (27.2 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 62 bytes 6154 (6.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 20 bytes 1800 (1.7 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 20 bytes 1800 (1.7 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
(the 2001:db8::2 IPv6 address is a address for documentation, I know… of course I have a real ip address assigned)
the network inside the container:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
19: eth0@if20: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
link/ether 02:42:ac:19:00:02 brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet 172.25.0.2/16 brd 172.25.255.255 scope global eth0
valid_lft forever preferred_lft forever
the /etc/hosts file inside the container
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.25.0.2 mail.example.com mail
I also can ping the localhost, so I do not understand why the 127.0.0.1 should be a bad address?
Improvements to this form?
No response
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 17 (10 by maintainers)
Hey, did you miss our docs for IPv6? They’re quite decent on how to configure that correctly last I checked.
You can have IPv4 in Docker but IPv6 only on the host AFAIK, or only exposing an IPv6 interface to the internet at least. What happens is the IPv6 connection can be routed to an IPv4 only Docker container, as the IP assigned by Dockers default bridge networking is private network it manages for you. It handles the routing and all that other config you were messing with like
/etc/resolv.conf, you really shouldn’t need to touch any of that 😃If you want to change the DNS service used, you can use
--dns 8.8.8.8with adocker runcommand, or for docker compose thedns:setting on thecompose.yamlservice.I don’t really encourage using that IPv6 prefix, it was intended only for documentation. You should use one from ULA (see our docs for more info). The configuration should be much simpler 😃
Let’s ripgrep and replace to kick things off. That can go into v14.
I think IPv6 support in DMS is a bit lacking elsewhere (
PERMIT_DOCKER), so probably no rush with only a single user report (though contributions are welcome!). The fix shouldn’t be too difficult though in this case, probably just need to use ripgrep on the repo for127.0.0.1and consider replacing withlocalhost?The issue is about IPv6 not being compatible with Amavis due to this:
https://github.com/docker-mailserver/docker-mailserver/blob/016d6b5255be6945b08616a79f92f496a583b775/target/amavis/postfix-amavis.cf#L15
Which uses IPv4 which is not compatible with Postfix
inet_protocolswhen set to IPv6:https://github.com/docker-mailserver/docker-mailserver/blob/016d6b5255be6945b08616a79f92f496a583b775/target/scripts/startup/setup.d/postfix.sh#L17-L20
FWIW, usually your DMS container is on a bridge network managed by Docker, not host networking mode. I’m not sure what the situation is like with say kubernetes, but AFAIK it’s the same scenario where you control the public network interface that the container ports are published to.
If you only want IPv6, configure your DNS records accordingly and only make the container available via IPv6 on the container host. AFAIK you just place the interface IP on the host to bind to as a prefix to your port mapping, alternatively you can listen to all interfaces on IPv4 (
0.0.0.0) or IPv6 ([::/0]?) exclusively (test to verify this).This is useful when you want to publish ports for accessing a containerized service on the host system, but not accidentally publish these ports to the network interfaces other than loopback, preventing public access.
127.0.0.1:80:8080instead of80:8080for example is a secure way to make the container only accessible locally. Note that firewalls don’t prevent Dockers port publishing from public access without that, the port publishing managed by Docker directly via iptables will punch through any firewall rules to block access IIRC.Thus to resolve this bug, the reporter is correct that the adjustment needs to be made. Using
localhostinstead should work fine and be compatible with all modes?The referenced location above with
127.0.0.1may not be the only configuration to amend however, as I think other services and config files / scripts use127.0.0.1or similar IPv4 without taking this into account.NOTE: loopback IP /
localhostrestricts listening to within the container on that port, another container or the host cannot connect over that (hence0.0.0.0/[::/0]when this is needed to listen on all interfaces/networks connected to the container).Doesn’t that prevent IPv4? Thus
127.0.0.1?Whereas the
localhostchange can resolve to both IPv4 and IPv6 loopback (127.0.0.1/[::1]), as per/etc/hostsfile in the container.