November 01, 2018
This lab demonstrated how to use Swarm to orchestrate multiple containers to form services and work as a stack. The stack exposes its functional components as services, each service could be distributed to multiple worker nodes as task replicas (one container per replica). At last, we see how to dynamically scale up the task replicas of a service.
To build up architecture as below,
docker swarm init --advertise-addr $(hostname -i)
docker swarm join --token <join token> <manager node IP:port>
A stack is a group of services that are deployed together: multiple containerized components of an application that run in separate instances. Each individual service can actually be made up of one or more containers, called tasks and then all the tasks & services together make up a stack.
git clone https://github.com/docker/example-voting-app
cd example-voting-app
The docker-stack.yml YAML file defines our entire stack: the architecture of the services, number of instances, how everything is wired together, how to handle updates to each service. It is the source code for our application design.
docker stack deploy --compose-file=docker-stack.yml voting_stack
docker stack ls
docker stack services voting_stack
docker service ps voting_stack_vote
docker service scale voting_stack_vote=5
Written by Warren who studies distributed systems at George Washington University. You might wanna follow him on Github