Create a swarm cluster on AWS with Docker 1.12 (swarm mode) running two test services

Create a swarm cluster on AWS with Docker 1.12 (swarm mode) running two test services

Tools required:
docker 1.12.0
docker-machine 0.8.0
docker-compose 1.8.0
Kitematic 0.12.0
Boot2Docker ISO 1.12.0
VirtualBox 5.0.24
AWS CLI 1.7.36

AWS CLI assumes credenitals already set
c:\users\xxxx\.aws\credentials
[default]
aws_secret_access_key=xxxxxxxxx
aws_access_key_id=xxxxxxxxxxxx

Spin up swarm cluster (swarm mode) in AWS

docker-machine create --driver amazonec2 --amazonec2-region eu-west-1   aws-swarm-manager
docker-machine create --driver amazonec2 --amazonec2-region eu-west-1   aws-swarm-node-1
docker-machine create --driver amazonec2 --amazonec2-region eu-west-1   aws-swarm-node-2
docker-machine create --driver amazonec2 --amazonec2-region eu-west-1   aws-swarm-node-3
docker-machine create --driver amazonec2 --amazonec2-region eu-west-1   aws-swarm-node-4
docker-machine create --driver amazonec2 --amazonec2-region eu-west-1   aws-swarm-node-5

docker-machine ip aws-swarm-manager > manager_ip.txt
set /p MANAGER_IP=< manager_ip.txt

docker-machine ssh aws-swarm-manager docker swarm-manager init --advertise-addr %MANAGER_IP%

docker-machine ssh aws-swarm-manager docker swarm join-token --quiet manager >manager_token.txt
set /p MANAGER_TOKEN=<manager_token.txt

docker-machine ssh aws-swarm-manager docker swarm join-token --quiet worker >worker_token.txt
set /p WORKER_TOKEN=<worker_token.txt

docker-machine ssh aws-swarm-node-1 docker swarm join --token %MANAGER_TOKEN% %MANAGER_IP%:2377
docker-machine ssh aws-swarm-node-2 docker swarm join --token %MANAGER_TOKEN% %MANAGER_IP%:2377
docker-machine ssh aws-swarm-node-3 docker swarm join --token %WORKER_TOKEN% %MANAGER_IP%:2377
docker-machine ssh aws-swarm-node-4 docker swarm join --token %WORKER_TOKEN%  %MANAGER_IP%:2377
docker-machine ssh aws-swarm-node-5 docker swarm join --token %WORKER_TOKEN%  %MANAGER_IP%:2377

docker-machine ssh aws-swarm-manager docker network create -d overlay aspennetwork

docker-machine ssh aws-swarm-manager docker service create --name web --network aspennetwork --replicas 10 -p 5001:80 francois/apache-hostname

docker-machine ssh aws-swarm-manager docker service create --replicas 3 --name helloworld alpine ping docker.com

Comments

Post a Comment

Popular posts from this blog

Basic Send Message to MQ with Java and IBM MQ JMS

Basic Receive Message to MQ with Java and IBM MQ JMS