问题现象
docker容器起来以后,查看9100端口监听情况,如下图:
$ ss -lntp
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:22 *:* users:(("sshd",pid=1151,fd=3))
LISTEN 0 4096 [::]:9100 [::]:* users:(("node_exporter",pid=2147,fd=3))
LISTEN 0 128 [::]:22 [::]:* users:(("sshd",pid=1151,fd=4))
9100只监听在ipv6上,使用ipv4无法访问。
解决办法如下:
编辑/etc/default/grub
,在第六行前面加入ipv6.disable=1
:
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=0
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="ipv6.disable=1 crashkernel=auto spectre_v2=retpoline rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet"
GRUB_DISABLE_RECOVERY="true"
保存后重新配置grub并重启服务器
$ grub2-mkconfig -o /boot/grub2/grub.cfg
$ reboot
重启后结果:
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:22 *:* users:(("sshd",pid=1133,fd=3))
LISTEN 0 100 127.0.0.1:25 *:* users:(("master",pid=1295,fd=13))
LISTEN 0 4096 *:9100 *:* users:(("node_exporter",pid=1732,fd=3))