Outline
All the tutorials in this course:
- What Is Server Virtualization?
- An Introduction to Docker
- Other Docker Tools
- An Introduction to Kubernetes
- Working With Kubernetes
Just why would anyone want to spread their Docker resources across more than a single host? Well think about what kinds of workloads are being run on container infrastructure these days. Enterprise-class applications require enterprise-class servers to run them reliably. That means you'll need enough compute and network power to handle whatever levels of user demand that'll get thrown your way. You can easily imagine how it's unlikely that a single server - or even a single data center location - will be able to consistently deliver that power. So something's going to have to coordinate all the servers and connectivity resources you'll eventually launch. And that "something" may well turn out to be Docker Swarm.
In the context of Swarm, there are two kinds of nodes: managers and workers. To put swarm nodes to work, I can launch a Service from the manager node. The simple example shown in the video here will order up two concurrent replicas of that newimage
image I created earlier. Even though the image already exists on my manager node, I'm going to reference the copy we pushed to Docker Hub. That's because the worker node won't otherwise have access to the local copy currently living on my manager node.
I can change the number of nodes I want running by running service scale
. This execution will reduce the number of nodes from 2 to 1. When I run ps
again I can see that one of my nodes is in the process of being removed. After a few seconds, that node will drop out completely. Finally, I'll knock out the service altogether by scaling down to zero. Again, after waiting for a bit, we'll confirm that the desired state has been achieved.
docker service create --replicas 2 \
--name myservice dbclinton/newimage:latest
docker service ls
docker service inspect --pretty myservice
docker service ps myservice
docker service scale myservice=1
docker service scale myservice=0