zoukankan      html  css  js  c++  java
  • 解决CentOS7 docker容器映射端口只监听ipv6的问题

    问题现象

    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))
    
  • 相关阅读:
    Dockerize a .NET Core application
    Images之管理image
    Images之Dockerfile中的命令2
    Images之Dockerfile中的命令1
    Docker Builders:Builder pattern vs. Multi-stage builds in Docker
    Images之multi-stage builds
    Images之base image
    Images之Dockerfiles
    Docker 开发最佳实践
    Docker 开发概述
  • 原文地址:https://www.cnblogs.com/Aaron-23/p/14955545.html
Copyright © 2011-2022 走看看