• 在esx上 docker的网络桥接


    docker:/root# docker run -itd --net=none --name zjtest8_haproxy   192.168.32.150:5000/zjzc_centos6.5_m1  bash
    d460fd1a2b320a9c9eb3f4e41009bc649043d975cbb5fafa2d5b98138951b6e1
    
    docker:/root# docker ps
    CONTAINER ID        IMAGE                                   COMMAND             CREATED             STATUS              PORTS               NAMES
    d460fd1a2b32        192.168.32.150:5000/zjzc_centos6.5_m1   "bash"              3 seconds ago       Up 3 seconds                            zjtest8_haproxy 
    
    
    docker:/root# docker exec -it d460fd1a2b32
    docker: "exec" requires a minimum of 2 arguments.
    See 'docker exec --help'.
    
    Usage: docker exec [OPTIONS] CONTAINER COMMAND [ARG...]
    
    Run a command in a running container
    docker:/root# docker exec -it d460fd1a2b32 bash
    bash-4.1# /sbin/ifconfig -a
    lo        Link encap:Local Loopback  
              inet addr:127.0.0.1  Mask:255.0.0.0
              inet6 addr: ::1/128 Scope:Host
              UP LOOPBACK RUNNING  MTU:65536  Metric:1
              RX packets:0 errors:0 dropped:0 overruns:0 frame:0
              TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:0 
              RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
    
    
    
    当前没有网络:
    
    
    宿主机重启  默认docker容器不会启动:
    
    docker:/root# docker ps
    CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
    
    docker:/root# docker ps -a
    CONTAINER ID        IMAGE                                   COMMAND             CREATED             STATUS                        PORTS               NAMES
    d460fd1a2b32        192.168.32.150:5000/zjzc_centos6.5_m1   "bash"              5 minutes ago       Exited (137) 38 seconds ago                       zjtest8_haproxy   
    
    
    pipework bro  d460fd1a2b32   192.168.32.152/24@192.168.32.254  
    
    docker:/root# pipework bro  d460fd1a2b32   192.168.32.152/24
    "up" is invalid lladdr
    
    
    docker:/root# pipework br0 -i eth1 d460fd1a2b32 192.168.32.152/24@192.168.32.254
    
    
    docker 容器 停止后,再启动地址也会丢失:
    
    
    
    
    
    
    eth0 上的地址配置给br0
    docker:/etc/sysconfig/network-scripts# vim ifcfg-eth0
    
    DEVICE=eth2
    TYPE=Ethernet
    UUID=ac880d1b-2e37-425b-a58e-2a1e4625255c
    ONBOOT=yes
    NM_CONTROLLED=yes
    BOOTPROTO=none
    BRIDGE=br0
    #IPADDR=192.168.32.151
    #NETMASK=255.255.255.0
    #GATEWAY=192.168.32.254
    
    docker:/etc/sysconfig/network-scripts# cat ifcfg-br0 
    DEVICE=br0
    TYPE=Bridge
    ONBOOT=yes
    NM_CONTROLLED=yes
    BOOTPROTO=static
    IPADDR=192.168.32.151
    NETMASK=255.255.255.0
    GATEWAY=192.168.32.254
    DNS1=8.8.8.8
    
    
    
    宿主机网络:
    
    docker:/root# /sbin/ifconfig -a
    br0       Link encap:Ethernet  HWaddr 00:0C:29:6E:56:02  
              inet addr:192.168.32.151  Bcast:192.168.32.255  Mask:255.255.255.0
              inet6 addr: fe80::20c:29ff:fe6e:5602/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:106 errors:0 dropped:0 overruns:0 frame:0
              TX packets:65 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:0 
              RX bytes:7526 (7.3 KiB)  TX bytes:6971 (6.8 KiB)
    
    docker0   Link encap:Ethernet  HWaddr 96:F9:9F:F9:C6:6D  
              inet addr:172.17.42.1  Bcast:0.0.0.0  Mask:255.255.0.0
              inet6 addr: fe80::94f9:9fff:fef9:c66d/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:0 errors:0 dropped:0 overruns:0 frame:0
              TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:0 
              RX bytes:0 (0.0 b)  TX bytes:468 (468.0 b)
    
    eth2      Link encap:Ethernet  HWaddr 00:0C:29:6E:56:02  
              inet6 addr: fe80::20c:29ff:fe6e:5602/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:108 errors:0 dropped:0 overruns:0 frame:0
              TX packets:73 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:9130 (8.9 KiB)  TX bytes:7619 (7.4 KiB)
    
    lo        Link encap:Local Loopback  
              inet addr:127.0.0.1  Mask:255.0.0.0
              inet6 addr: ::1/128 Scope:Host
              UP LOOPBACK RUNNING  MTU:65536  Metric:1
              RX packets:0 errors:0 dropped:0 overruns:0 frame:0
              TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:0 
              RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
    
    
    
    宿主机网络正常:
    docker:/root# ping baidu.com
    PING baidu.com (111.13.101.208) 56(84) bytes of data.
    
    64 bytes from 111.13.101.208: icmp_seq=1 ttl=51 time=30.5 ms
    64 bytes from 111.13.101.208: icmp_seq=2 ttl=51 time=29.2 ms
    64 bytes from 111.13.101.208: icmp_seq=3 ttl=51 time=29.4 ms
    64 bytes from 111.13.101.208: icmp_seq=4 ttl=51 time=28.9 ms
    
    
    
    
    

  • 相关阅读:
    Java动态绑定与多态
    Java中的equals,==,compareTo和compare的比较
    Java访问控制权限
    如何用eclipse进行jar文件打包?
    堆和栈的区别
    Java命名规则
    Java面向对象的基本概念
    java中length,length(),size()区别
    《剑指offer》第二十题:表示数值的字符串
    《剑指offer》第十九题:正则表达式匹配
  • 原文地址:https://www.cnblogs.com/zhaoyangjian724/p/6200283.html
Copyright © 2020-2023  润新知