-
-
Save yamamoto-febc/5d1d1b43cbae8cb51c43b2f2c0241312 to your computer and use it in GitHub Desktop.
docker v1.12のオーケストレーション機能をマルチホストで試すよ on さくらのクラウド ref: http://qiita.com/yamamoto-febc/items/afc7143e609c170140e6
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台目のマシンに接続 | |
$ eval $(docker-machine env sakura01) | |
# init実施 | |
$ docker swarm init | |
Swarm initialized: current node (bvotc0o2ukxbeud6jedhpyvsq) is now a manager. |
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-machine ip sakura01 |
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 service --help | |
Usage: docker service COMMAND | |
Manage Docker services | |
Options: | |
--help Print usage | |
Commands: | |
create Create a new service | |
inspect Inspect a service | |
tasks List the tasks of a service | |
ls List services | |
rm Remove a service | |
scale Scale one or multiple services | |
update Update a service | |
Run 'docker service COMMAND --help' for more information on a command. | |
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 service create --replicas 1 --name hellosakura -p 80:80 nginx:latest |
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 init --help | |
Usage: docker swarm init [OPTIONS] | |
Initialize a Swarm | |
Options: | |
--auto-accept value Auto acceptance policy (worker, manager, or none) | |
--force-new-cluster Force create a new cluster from current state. | |
--help Print usage | |
--listen-addr value Listen address (default 0.0.0.0:2377) | |
--secret string Set secret value needed to accept nodes into cluster |
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 node ls | |
ID NAME MEMBERSHIP STATUS AVAILABILITY MANAGER STATUS | |
bvotc0o2ukxbeud6jedhpyvsq * sakura01 Accepted Ready Active Leader | |
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 join --help | |
Usage: docker swarm join [OPTIONS] HOST:PORT | |
Join a Swarm as a node and/or manager | |
Options: | |
--ca-hash string Hash of the Root Certificate Authority certificate used for trusted join | |
--help Print usage | |
--listen-addr value Listen address (default 0.0.0.0:2377) | |
--manager Try joining as a manager. | |
--secret string Secret for node acceptance | |
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
# 2台目のマシンへ接続 | |
$ eval $(docker-machine env sakura02) | |
# join | |
$ docker swarm join `docker-machine ip sakura01`:2377 | |
This node joined a Swarm as a worker. | |
# 3台目のマシンへ接続 | |
$ eval $(docker-machine env sakura03) | |
# join | |
$ docker swarm join `docker-machine ip sakura01`:2377 | |
This node joined a Swarm as a worker. | |
# 1台目に接続して確認 | |
$ eval $(docker-machine env sakura01) | |
$ docker node ls | |
ID NAME MEMBERSHIP STATUS AVAILABILITY MANAGER STATUS | |
03qup39ksvhcgvusqk7o9x50h sakura03 Accepted Ready Active | |
bvotc0o2ukxbeud6jedhpyvsq * sakura01 Accepted Ready Active Leader | |
ccup7i31v4dbzip15ej49wpzm sakura02 Accepted Ready Active | |
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-machine create -d sakuracloud \ | |
--sakuracloud-access-token=[ACCESS TOKEN] \ | |
--sakuracloud-access-token-secret=[ACCESS TOKEN SECRET] \ | |
--engine-install-url="https://experimental.docker.com" \ | |
sakura01 | |
# 2台目 | |
$ docker-machine create -d sakuracloud \ | |
--sakuracloud-access-token=[ACCESS TOKEN] \ | |
--sakuracloud-access-token-secret=[ACCESS TOKEN SECRET] \ | |
--engine-install-url="https://experimental.docker.com" \ | |
sakura02 | |
# 3台目 | |
$ docker-machine create -d sakuracloud \ | |
--sakuracloud-access-token=[ACCESS TOKEN] \ | |
--sakuracloud-access-token-secret=[ACCESS TOKEN SECRET] \ | |
--engine-install-url="https://experimental.docker.com" \ | |
sakura03 |
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
$ open http://`docker-machine ip sakura01` | |
$ open http://`docker-machine ip sakura02` | |
$ open http://`docker-machine ip sakura03` |
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 service ls | |
ID NAME REPLICAS IMAGE COMMAND | |
2685cua3k8wm hellosakura 1/1 nginx:latest | |
# サービス内の各タスクの起動状況の確認(sakura03で起動しているのが見える) | |
$ docker service tasks hellosakura | |
ID NAME SERVICE IMAGE LAST STATE DESIRED STATE NODE | |
4zh6ppxmxncfm6guswtoixmho hellosakura.1 hellosakura nginx:latest Running 37 seconds Running sakura03 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment