• Docker动态给容器Container暴露端口


    查看Container的IP地址

    docker inspect <container name or id>| grep IPAddress

    查看Container的映射的端口

    docker port <container name or id>
    eg.
    docker port d8dac7399647

    用iptables查看容器映射情况

    iptables -t nat -nvL
    iptables -t nat -nvL --line-number

    举例新增端口的映射
    ##将主机31101 映射到 容器 6379端口

    iptables -t nat -A PREROUTING -p tcp -m tcp --dport 31101 -j DNAT --to-destination 192.168.42.2:6379

    保存iptables规则

    iptables-save

    说明

    192.168.42.2 是根据 docker inspect <container name or id>| grep IPAddress 的结果

    端口映射完毕后,不能通过docker port d8dac7399647查询到结果

    可以通过

    iptables -t nat -nvL | grep 192.168.42.2

    查询 映射关系

  • 相关阅读:
    课后作业一
    软工假期预习作业
    Spark2.0自定义累加器
    JAVA hashmap知识整理
    Spark 累加器
    RDD与DataFrame的转换
    Scala笔记整理
    Spark RDD
    Hbase的flush机制
    Spring源码-ImportSelector实现分析
  • 原文地址:https://www.cnblogs.com/caidingyu/p/10789906.html
Copyright © 2020-2023  润新知