forked from seriousben/fun-swarm-scheduler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·41 lines (30 loc) · 1005 Bytes
/
setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!env bash
set -e
#
# Env:
# DOCKER_SERVICE_PREFER_OFFLINE_IMAGE=1 let the docker engine prefer local images over registry images
#
docker-machine create -d virtualbox --engine-env DOCKER_SERVICE_PREFER_OFFLINE_IMAGE=1 node-1 &
#docker-machine create -d virtualbox node-1 &
NODE1_PID=$!
docker-machine create -d virtualbox --engine-env DOCKER_SERVICE_PREFER_OFFLINE_IMAGE=1 node-2 &
#docker-machine create -d virtualbox node-2 &
NODE2_PID=$!
wait $NODE1_PID
wait $NODE2_PID
docker-machine ls
# Init Manager
eval $(docker-machine env node-1)
docker swarm init --advertise-addr $(docker-machine ip node-1) --listen-addr $(docker-machine ip node-1):2377
TOKEN=$(docker swarm join-token -q worker)
echo "TOKEN=$TOKEN"
function joinSwarm() {
nodeName=$1
eval $(docker-machine env $nodeName)
docker swarm join --token $TOKEN $(docker-machine ip node-1):2377
}
joinSwarm "node-2"
eval $(docker-machine env node-1)
docker node ls
docker network create --driver overlay fun-swarm
docker network ls