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
    希望你眼眸有星辰,心中有山海,从此以梦为马,不负韶华
  • 相关阅读:
    Humidex
    Hangover(1.4.1)
    I Think I Need a Houseboat(1.3.1)
    Sum of Consecutive Prime Numbers
    Doubles
    Financial Management
    Nim算法------高僧斗法
    标题:猜灯谜
    银行管理系统
    三种例行程序(procdures,function,traps)的使用
  • 原文地址:https://www.cnblogs.com/daviddd/p/12661117.html
Copyright © 2011-2022 走看看