SHARE
TWEET

Untitled

a guest Mar 21st, 2017 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. docker network create -d macvlan
  2.     --subnet=192.168.100.1/24
  3.     -o parent=eth0 pub_net
  4.    
  5. docker create
  6.     --network pub_net
  7.     --ip=192.168.100.2
  8.     -h mycontainer
  9.     --name mycontainer
  10.     -ti
  11.     alpine
  12.     /bin/sh
  13.    
  14. docker network connect
  15.     --ip 192.168.100.3
  16.     --alias mycontainer-int2
  17.     pub_net
  18.     mycontainer
  19.    
  20. $ echo $?
  21. 0
  22.    
  23. $ docker start mycontainer
  24. mycontainer
  25. $ docker attach mycontainer
  26. / # ip a
  27. 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
  28.     link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
  29.     inet 127.0.0.1/8 scope host lo
  30.    valid_lft forever preferred_lft forever
  31. inet6 ::1/128 scope host
  32.    valid_lft forever preferred_lft forever
  33. 10: eth0@if2: <NO-CARRIER,BROADCAST,MULTICAST,UP,M-DOWN> mtu 1500 qdisc noqueue state LOWERLAYERDOWN
  34.     link/ether 02:42:c0:a8:c8:03 brd ff:ff:ff:ff:ff:ff
  35.     inet 192.168.200.3/24 scope global eth0
  36.    valid_lft forever preferred_lft forever
  37. / #
  38.    
  39. $ docker network inspect pub_net
  40. [
  41.     {
  42.         "Name": "pub_net",
  43.         "Id": "578df6fd9929b0c44356e32a04043b358c2a052e11377ee7430743cd48566203",
  44.         "Scope": "local",
  45.         "Driver": "macvlan",
  46.         "EnableIPv6": false,
  47.         "IPAM": {
  48.             "Driver": "default",
  49.             "Options": {},
  50.             "Config": [
  51.                 {
  52.                     "Subnet": "192.168.100.1/24"
  53.                 }
  54.             ]
  55.         },
  56.         "Internal": false,
  57.         "Containers": {
  58.             "7f2fd160b8f7340d75861c1c0f743820ee713b13738a1f09252b0b17da58f111": {
  59.                 "Name": "mycontainer",
  60.                 "EndpointID": "44af06571b1c6334001cbb13c15702640d93930e30f415052e684a96b0d0a893",
  61.                 "MacAddress": "02:42:c0:a8:c8:03",
  62.                 "IPv4Address": "192.168.100.3/24",
  63.                 "IPv6Address": ""
  64.             }
  65.         },
  66.         "Options": {
  67.             "parent": "eth0"
  68.         },
  69.         "Labels": {}
  70.     }
  71. ]
RAW Paste Data
Top