Docker will only bind forwarded ports to IPv6 interfaces
Solution 1:
I ran through the same issue:
Edit /etc/modprobe.d/blacklist.conf
with:
blacklist ipv6
And /etc/default/grub
with:
GRUB_CMDLINE_LINUX_DEFAULT="ipv6.disable=1 console=ttyS0"
Then update-grub
and reboot
.
Solution 2:
Actually, docker uses the netfilter firewall to make sure the service is available. lsof
wouldn't tell you anything. Try running
iptables -L -t nat
ip6tables -L -t nat
It is possible that the container doesn't listen to the specified port however.
You can look into your container to make sure your service is listening to the expected ports using nsenter:
nsenter --net -t PID netstat -ltpn
PID
must be the PID of a process running inside the container, most probably your service. --net
is to enter the network namespace. Then the netstat options -ltpn
is to list listening (-l
) TCP (-t
) sockets. Show the process (-p
), and show port numbers in numeric format (-n
).