zoukankan      html  css  js  c++  java
  • docker 容器的网络访问(端口映射)

    在Docker容器的日常使用中,有以下5种常见的端口映射方式

    - 对容器暴露的所有端口,随机映射宿主机端口
    -P , –publish-all=true | false,默认为false
    docker run -P -it ubuntu /bin/bash
    
    
    - 映射宿主机随机端口到容器指定端口
    -p containerPort( -p表示 –publish=[ ] )
    docker run -p 80 -it ubuntu /bin/bash
    
    
    - 映射宿主机指定端口到容器指定端口(一 一对应)
    hostPort : containerPort
    docker run -p 8080:80 -it ubuntu /bin/bash
    
    
    - 指定容器IP和容器端口,宿主机端口随机映射
    ip : : containerPort
    docker run -p 127.0.0.12::80 -it ubuntu /bin/bash
    
    
    - 指定容器IP、宿主机端口、容器端口
    ip : hostPort : containerPort
    
    docker run -p 127.0.0.12:8080:80 -it ubuntu /bin/bash
    

    IP规则

    查看ip规则
    iptables -t nat -L -n 
    
    添加子网ip
    ifconfig eth0:1 10.0.0.100/24 up
    希望你眼眸有星辰,心中有山海,从此以梦为马,不负韶华
  • 相关阅读:
    RQNOJ 34 紧急援救
    Codevs 2080 特殊的质数肋骨
    POJ2975 Nim
    Bzoj1016 最小生成树计数
    POJ3613 Cow Relays
    POJ1386 Play on Words
    [从hzwer神犇那翻到的模拟赛题] 合唱队形
    HDU2824 The Euler function
    HDU1576 A/B
    HDU2669 Romantic
  • 原文地址:https://www.cnblogs.com/daviddd/p/12661117.html
Copyright © 2011-2022 走看看