Docker 1.12 is on everyone's lips these day. With built in Swarm mode, we can achieve orchestration out of the box with simplicity, reliability, and effective scalability. I had the pleasure of presenting Docker 1.12 and Swarm at a DevOps meetup held at SA Home Loans.
You can read more info on my blog: http://blog.stratotechnology.com/intro-to-docker-1-12-and-swarm-mode/
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
Docker 1.12 and swarm mode
1. Docker 1.12 and Swarm
Presented By : Wesley Blake | Technical Director @Prop Data
http://blog.stratotechnology.com/intro-to-docker-1-12-and-swarm-mode/
https://github.com/WesleyCharlesBlake
2. Feature highlights
● Cluster management integrated with Docker Engine
● Decentralized design
● Declarative service model
● Scaling
● Desired state reconciliation
● Multi-host networking
● Service discovery
● Load balancing (Container-native load balancing.)
● Secure by default (Automated key rotation.)
● Rolling updates
3. swarm
● A swarm is a cluster of Docker Engines.
● Swarm mode is native in Docker 1.12 RC.
● When in swarm mode, you orchestrate
services.
$ docker swarm
Usage: docker swarm COMMAND
Manage Docker Swarm
Commands:
init Initialize a swarm
join Join a swarm as a node and/or manager
join-token Manage join tokens
update Update the swarm
leave Leave a swarm
4. node
● A node is a Docker Engine and a member of the swarm.
● There are two types of nodes, managers and workers.
● A manager node schedules service tasks on worker nodes.
● Manager nodes and worker nodes are both capable of executing
tasks.
$ docker node
Usage: docker node COMMAND
Manage Docker Swarm nodes
Commands:
demote Demote a node from manager in the swarm
inspect Display detailed information on one or more nodes
ls List nodes in the swarm
promote Promote a node to a manager in the swarm
rm Remove a node from the swarm
ps List tasks running on a node
update Update a node
5. {service,task}
● A service defines tasks that are
executed in the swarm.
● service = image + command
● A task is the scheduling and
execution of a service on a node.
$ docker service
Usage: docker service COMMAND
Manage Docker services
Commands:
create Create a new service
inspect Display detailed information on one or more services
ps List the tasks of a service
ls List services
rm Remove a service
scale Scale one or multiple services
update Update a service
6. Swarm CLI
$ swarm init
$ swarm join
$ service create
$ service inspect
$ service ls
$ service ps
$ service rm
$ service scale
$ service update
8. swarm init
$ eval $(docker-machine env manager1)
$ docker swarm init
--advertise-addr $(docker-machine ip manager1)
--listen-addr $(docker-machine ip
manager1):2377
# or ssh directly onto the host:
$ docker swarm init
--advertise-addr 192.168.99.100
--listen-add 192.168.99.100:2377
9. swarm join
$ docker swarm join-token worker
To add a worker to this swarm, run the following command:
docker swarm join
--token SWMTKN-1-4x502sygb5ws0wwmpevndnp4d55bbxsmts339ylpuh37kiy5sv-dl7jurksix80niuo2ncj9v0ak
192.168.99.100:2377
$ docker swarm join-token manager
To add a manager to this swarm, run the following command:
docker swarm join
--token SWMTKN-1-4x502sygb5ws0wwmpevndnp4d55bbxsmts339ylpuh37kiy5sv-79ugs5f3pwvv5jrom5b8dinhs
192.168.99.100:2377
$ docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
97zmo0c36dfj675dpg2q2rtg0 worker2 Ready Active
c0q0ckwe3h39fbu9sv33069fo worker3 Ready Active
cjzcy20zu8uarq6g2l8z4eg9n * manager1 Ready Active Leader
dmt4kjgeeem6bsqb2jcmvzuj1 worker1 Ready Active
10. service {create,inspect,ls}
docker service create
--replicas 1
--name vote
-p 8080:80
--network go-demo
--update-delay 10s
--update-parallelism 2
instavote/vote
$ docker service ls
ID NAME REPLICAS IMAGE COMMAND
1q10x534o7r7 vote 4/4 instavote/vote
$ docker service inspect --pretty vote
ID: 1q10x534o7r75eji2lvt32atu
Name: vote
Mode: Replicated
Replicas: 4
Placement:
UpdateConfig:
Parallelism: 2
Delay: 10s
On failure: pause
ContainerSpec:
Image: instavote/vote
Resources:
Networks: 52l8ayurqgh3a7937e7pcrttkPorts:
Protocol = tcp
TargetPort = 80
PublishedPort = 8080
11. service ps
$ docker service ps vote
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR
4a4kv8mul0z87l5xx6aetkcnq vote.1 instavote/vote worker1 Running Running 7 minutes ago
6p7bofib6y44ew4olsssqn1ht vote.2 instavote/vote worker2 Running Running 8 minutes ago
3s2cqdwdp57p5ehmtqggcj7kq vote.3 instavote/vote worker3 Running Running 8 minutes ago
2pbv6a7y2x0e74v85c61r5k41 vote.4 instavote/vote manager1 Running Running 7 minutes ago
DEMO this thing!
12. service scale
$ docker service scale vote=8
vote scaled to 8
$ docker service ls
ID NAME REPLICAS IMAGE COMMAND
1q10x534o7r7 vote 8/8 instavote/vote
$ docker service scale vote=8 redis=3
vote scaled to 8
$ docker service ls
ID NAME REPLICAS IMAGE COMMAND
1q10x534o7r7 vote 8/8 instavote/vote
9sjd1xLX781a redis 3/3 redis
13. service update
docker service update --image instavote/vote:movies vote
# can result in down time during the update
# perform a rolling update:
docker service update --update-parallelism 2 --update-delay 5s --image instavote/vote:movies
vote
#updates 2 tasks simultaneously, delay of 5s between update,
14. The end! Blog -> http://blog.stratotechnology.com
Github -> @WesleyCharlesBlake