Created
August 22, 2016 19:59
-
-
Save lucj/656d810762f9e1c54414615680a58f8e to your computer and use it in GitHub Desktop.
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 Raspberry one PI 2 B+ and one PI 3 running Raspbian | |
Version | |
pi@pi2:~ $ docker version | |
Client: | |
Version: 1.12.1 | |
API version: 1.24 | |
Go version: go1.6.3 | |
Git commit: 23cf638 | |
Built: Thu Aug 18 05:31:15 2016 | |
OS/Arch: linux/arm | |
Server: | |
Version: 1.12.1 | |
API version: 1.24 | |
Go version: go1.6.3 | |
Git commit: 23cf638 | |
Built: Thu Aug 18 05:31:15 2016 | |
OS/Arch: linux/arm | |
—— | |
pi@pi3:~ $ docker version | |
Client: | |
Version: 1.12.1 | |
API version: 1.24 | |
Go version: go1.6.3 | |
Git commit: 23cf638 | |
Built: Thu Aug 18 05:31:15 2016 | |
OS/Arch: linux/arm | |
Server: | |
Version: 1.12.1 | |
API version: 1.24 | |
Go version: go1.6.3 | |
Git commit: 23cf638 | |
Built: Thu Aug 18 05:31:15 2016 | |
OS/Arch: linux/arm | |
Swarm creation | |
# init on pi2 | |
pi@pi2:~ $ docker swarm init —listen-addr=192.168.1.30 | |
Swarm initialized: current node (dypil1ss5y7bfiogoclqljrrk) is now a manager. | |
To add a worker to this swarm, run the following command: | |
docker swarm join \ | |
--token SWMTKN-1-27dpgcqo17jx3wrpqnc8dsmw6mrmyxz7ajwukugu5z9g09tj6o-d5ncsiqxjo3fjd6lry1mezi0o \ | |
192.168.1.30:2377 | |
To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions. | |
# Join pi3 as worker | |
pi@pi3:~ $ docker swarm join --token SWMTKN-1-27dpgcqo17jx3wrpqnc8dsmw6mrmyxz7ajwukugu5z9g09tj6o-d5ncsiqxjo3fjd6lry1mezi0o --listen-addr=192.168.1.27:2377 192.168.1.30:2377 | |
This node joined a swarm as a worker. | |
# List nodes from pi2 | |
pi@pi2:~ $ docker node ls | |
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS | |
951fn3olxkdmvuq3fcrjerfoe pi3 Ready Active | |
dypil1ss5y7bfiogoclqljrrk * pi2 Ready Active Leader | |
Scenario 1 | |
# Create service | |
pi@pi2:~ $ docker service create --name ping1 --replicas=2 alexellis2/pingcurl:armv6 ping docker.com | |
0u6xw2tbihd6v8zzoselo6evo | |
# List tasks | |
pi@pi2:~ $ docker service ps ping1 | |
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR | |
f1qaaz351wh0jadzhp0vai1yb ping1.1 alexellis2/pingcurl:armv6 pi2 Running Running 21 seconds ago | |
3kltatqetk8vslkdlya6ej2b1 ping1.2 alexellis2/pingcurl:armv6 pi3 Running Running 20 seconds ago | |
# => one task running on pi2, one running on pi3 | |
# task running on p2 | |
pi@pi2:~ $ docker ps | |
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES | |
2e78a0d48a55 alexellis2/pingcurl:armv6 "/usr/bin/entry.sh pi" 43 seconds ago Up 39 seconds ping1.1.f1qaaz351wh0jadzhp0vai1yb | |
pi@pi2:~ $docker logs 2e78a0d48a55 | |
pi@pi2:~ $ | |
# task running on p3 | |
pi@pi3:~ $ docker ps | |
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES | |
5beb9423b357 alexellis2/pingcurl:armv6 "/usr/bin/entry.sh pi" About a minute ago Up About a minute ping1.2.3kltatqetk8vslkdlya6ej2b1 | |
pi@pi3:~ $ docker logs 5beb9423b357 | |
pi@pi3:~ $ | |
Scenario 2 | |
# Run service from pi2 (manager node) | |
pi@pi2:~ $ docker service create --name hello1 --publish 3000:3000 --replicas=2 alexellis2/arm-alpinehello | |
8z5h5qf5n1j32mcx92sla1xjm | |
# Check services are running | |
pi@pi2:~ $ docker service ls | |
ID NAME REPLICAS IMAGE COMMAND | |
8z5h5qf5n1j3 hello1 2/2 alexellis2/arm-alpinehello | |
# Where are they running ? | |
pi@pi2:~ $ docker service ps hello1 | |
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR | |
5il0spuiy2hunuxjzvhaoj0y1 hello1.1 alexellis2/arm-alpinehello pi2 Running Running 40 seconds ago | |
26wfce180j0s00k29fal3e4be hello1.2 alexellis2/arm-alpinehello pi3 Running Running about a minute ago | |
# Curl localhost on pi2 | |
pi@pi2:~ $ curl -4 localhost:3000 | |
Hello | |
# Curl localhost on pi3 | |
pi@pi3:~ $ curl -4 localhost:3000 | |
Hello | |
Scenario 3 | |
# Create network | |
pi@pi2:~ $ docker network create --driver overlay armnet | |
a6062go6yn41j3u8m2tqjn84u | |
# Create services | |
pi@pi2:~ $ docker service create --replicas=1 --network=armnet --name redis alexellis2/redis-arm:v6 | |
1bjarom5tti9de39cuffoe3wg | |
pi@pi2:~ $ docker service create --name counter --replicas=2 --network=armnet --publish 3000:3000 alexellis2/arm_redis_counter | |
278inkcchuh7otc2mcfknri1i | |
# Check services are running | |
pi@pi2:~ $ docker service ls | |
ID NAME REPLICAS IMAGE COMMAND | |
1bjarom5tti9 redis 1/1 alexellis2/redis-arm:v6 | |
aep1mxoqbb4o counter 1/2 alexellis2/arm_redis_counter | |
# Counter does not run on both nodes | |
pi@pi2:~ $ docker service ps counter | |
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR | |
8ewp7umdor4rlqu6rihi6aqjj counter.1 alexellis2/arm_redis_counter pi2 Running Preparing 28 seconds ago | |
9324wg74eekks6xh6p8ityw4f counter.2 alexellis2/arm_redis_counter pi3 Running Running 12 seconds ago | |
2wo33qajsqh5ur4j6vgos0ppf \_ counter.2 alexellis2/arm_redis_counter pi2 Shutdown Rejected 27 seconds ago "failed to allocate gateway (1…" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment