Created
November 12, 2019 14:23
-
-
Save rwos/2509402a79e10bde3b4f2e629339ccc0 to your computer and use it in GitHub Desktop.
local docker swarm cluster with docker-machine
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
SHELL=/bin/bash | |
all: | |
-$(MAKE) clean | |
$(MAKE) start | |
$(MAKE) join | |
start: | |
docker-machine create --driver virtualbox d1 | |
docker-machine create --driver virtualbox d2 | |
docker-machine create --driver virtualbox d3 | |
clean: | |
docker-machine rm -f -y d1 | |
docker-machine rm -f -y d2 | |
docker-machine rm -f -y d3 | |
join: | |
$(eval MASTER_IP := $(shell docker-machine ip d1)) | |
@echo Master IP: $(MASTER_IP) | |
$(eval JOIN_CMD := $(shell \ | |
docker-machine ssh d1 "docker swarm init --advertise-addr $(MASTER_IP)" | \ | |
grep "docker swarm join --token")) | |
@echo Join Commmand: $(JOIN_CMD) | |
# join workers | |
docker-machine ssh d2 "$(JOIN_CMD)" | |
docker-machine ssh d3 "$(JOIN_CMD)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment