Created
December 2, 2015 16:32
-
-
Save yamamoto-febc/8300f422cad90c8e9b23 to your computer and use it in GitHub Desktop.
[実践編]docker + さくらのクラウドでマルチホストなoverlayネットワークしてみるよ(実施編) ref: http://qiita.com/yamamoto-febc/items/a5ac22cc9d6e1a980427
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ docker network create -d overlay [ネットワーク名] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# dockerコマンドでswarmマネージャへ接続するように設定 | |
$ eval "$(docker-machine env --swarm sakura-is1a-manager)" | |
# オーバーレイネットワーク作成 | |
$ docker network create -d overlay ishikari-network | |
# ネットワークの確認 | |
$ docker network ls | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# container1からcontainer3へping | |
$ docker exec -it container3 ping container2 -c4 | |
ping: bad address 'container2' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ docker network connect [ネットワーク名] [コンテナ名] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ docker network connect ishikari-network container3 | |
Error response from daemon: invalid container <nil> : nosuchcontainer: no such id: container3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NETWORK ID NAME DRIVER | |
b0decb567506 sakura-is1a-manager/bridge bridge | |
00cfbc40125e sakura-is1a-manager/host host | |
4ba8ceef0a1a sakura-is1a-manager/none null | |
735df4903fab sakura-is1a-agent/bridge bridge | |
45303217fec0 sakura-is1a-agent/host host | |
82d3bb7aa67f sakura-is1a-agent/none null | |
0723a7abc577 sakura-is1b-agent/bridge bridge | |
18752fd515f3 sakura-is1b-agent/host host | |
3c23e015b47a sakura-is1b-agent/none null | |
d09b4b43c662 sakura-tk1a-agent/bridge bridge | |
c1bc94509cab sakura-tk1a-agent/host host | |
bd64ec929e31 sakura-tk1a-agent/none null | |
452a2a1149fa ishikari-network overlay |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 石狩第1で起動,ネットワーク指定あり | |
docker run -itd --name=container1 --net=ishikari-network --env="constraint:node==sakura-is1a-agent" busybox | |
# 石狩第2で起動,ネットワーク指定あり | |
docker run -itd --name=container2 --net=ishikari-network --env="constraint:node==sakura-is1b-agent" busybox | |
# 東京第1で起動,ネットワーク指定なし | |
docker run -itd --name=container3 --env="constraint:node==sakura-tk1a-agent" busybox | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#各コンテナに対し以下を実施 | |
$ docker exec -it [コンテナ名,先ほど--nameオプションで指定したやつ] /bin/sh | |
#コンテナ内でshが起動するため、ip addrコマンド実施 | |
[container1]$ ip addr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/ # ip addr | |
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue | |
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 | |
inet 127.0.0.1/8 scope host lo | |
valid_lft forever preferred_lft forever | |
inet6 ::1/128 scope host | |
valid_lft forever preferred_lft forever | |
8: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc noqueue | |
link/ether 02:42:0a:00:00:02 brd ff:ff:ff:ff:ff:ff | |
inet 10.0.0.2/24 scope global eth0 | |
valid_lft forever preferred_lft forever | |
inet6 fe80::42:aff:fe00:2/64 scope link | |
valid_lft forever preferred_lft forever | |
11: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue | |
link/ether 02:42:ac:12:00:02 brd ff:ff:ff:ff:ff:ff | |
inet 172.18.0.2/16 scope global eth1 | |
valid_lft forever preferred_lft forever | |
inet6 fe80::42:acff:fe12:2/64 scope link | |
valid_lft forever preferred_lft forever |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/ # ip addr | |
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue | |
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 | |
inet 127.0.0.1/8 scope host lo | |
valid_lft forever preferred_lft forever | |
inet6 ::1/128 scope host | |
valid_lft forever preferred_lft forever | |
8: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc noqueue | |
link/ether 02:42:0a:00:00:03 brd ff:ff:ff:ff:ff:ff | |
inet 10.0.0.3/24 scope global eth0 | |
valid_lft forever preferred_lft forever | |
inet6 fe80::42:aff:fe00:3/64 scope link | |
valid_lft forever preferred_lft forever | |
11: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue | |
link/ether 02:42:ac:12:00:02 brd ff:ff:ff:ff:ff:ff | |
inet 172.18.0.2/16 scope global eth1 | |
valid_lft forever preferred_lft forever | |
inet6 fe80::42:acff:fe12:2/64 scope link | |
valid_lft forever preferred_lft forever |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/ # ip addr | |
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue | |
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 | |
inet 127.0.0.1/8 scope host lo | |
valid_lft forever preferred_lft forever | |
inet6 ::1/128 scope host | |
valid_lft forever preferred_lft forever | |
7: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue | |
link/ether 02:42:ac:11:00:03 brd ff:ff:ff:ff:ff:ff | |
inet 172.17.0.3/16 scope global eth0 | |
valid_lft forever preferred_lft forever | |
inet6 fe80::42:acff:fe11:3/64 scope link | |
valid_lft forever preferred_lft forever |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ docker exec -it container1 ping container2 -c4 | |
PING container2 (10.0.0.3): 56 data bytes | |
64 bytes from 10.0.0.3: seq=0 ttl=64 time=0.727 ms | |
64 bytes from 10.0.0.3: seq=1 ttl=64 time=0.599 ms | |
64 bytes from 10.0.0.3: seq=2 ttl=64 time=0.563 ms | |
64 bytes from 10.0.0.3: seq=3 ttl=64 time=0.595 ms | |
--- container2 ping statistics --- | |
4 packets transmitted, 4 packets received, 0% packet loss | |
round-trip min/avg/max = 0.563/0.621/0.727 ms |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# container1からcontainer3へping | |
$ docker exec -it container1 ping container3 -c4 | |
ping: bad address 'container3' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment