Prerequisites: docker-engine 1.13, bash, awscli (if you're spinning up aws docker-machines). Includes portainer for example web management of swarm and a run_machine script which runs a command on all docker-machines created from a host.
Example deployment of a docker-compose V3 stack onto a 1.13+ swarm
-
build example stack:
./run-swarm.sh build
-
run stack on swarm (ignore errors about pre-existing stacks):
./run-swarm.sh run
-
After a few seconds, test service
curl localhost:8080
-
scale example service:
./run-swarm.sh scale
-
remove stack from swarm:
./run-swarm.sh rm
To run this or your own example on an AWS EC2 Swarm using Docker-Machine:
-
Edit your AWS credentials and desired EC2 configuration flags into scripts/swarm_setup.sh and make sure the awscli binary is setup for your aws account.
-
Execute
./swarm_setup.sh
to create a multi-host swarm cluster to your specification -
Access your manager node using
docker-machine ssh <NODE_NAME>
-
Copy the repo onto your swarm manager and execute
./run-swarm.sh run
. The first node created will be the Swarm Manager.