Dockercoins On Swarm
By the end of this exercise, you should be able to:
- Deploy an application on swarm as a 'stack', using a docker compose file
- Get some high-level monitoring information about the services and tasks running as part of a stack
Deploying a Stack
Deploy Dockercoins as a stack on your swarm, from
node-0:[centos@node-0 ~]$ cd ~/orchestration-workshop/dockercoins [centos@node-0 dockercoins]$ docker stack deploy -c=docker-compose.yml dcCheck and see how your services are doing:
[centos@node-0 dockercoins]$ docker stack services dc ID NAME MODE REPLICAS IMAGE PORTS 7tcaa3d3g9d2 dc_webui replicated 1/1 training/dockercoins_webui:1.0 *:8000->80/tcp mfq8i9cr4rcj dc_rng replicated 1/1 training/dockercoins_rng:1.0 *:8001->80/tcp sbywya5yyrus dc_redis replicated 1/1 redis:latest tk1ydqu794ng dc_hasher replicated 1/1 training/dockercoins_hasher:1.0 *:8002->80/tcp v6835nwsek2n dc_worker replicated 1/1 training/dockercoins_worker:1.0Notice the
REPLICAScolumn in the output of above command; this shows how many of your desired replicas are running. At first, a few might show 0/1; before those tasks can start, the worker nodes will need to download the appropriate images from Docker Hub.Wait a minute or two, and try
docker stack services dcagain; once all services show 100% of their replicas are up, things are running properly and you can point your browser to port 8000 on one of the swarm nodes (does it matter which one?). You should see a graph of your dockercoin mining speed, around 3 hashes per second.Finally, check out the details of the tasks running in your stack with
stack ps:[centos@node-0 dockercoins]$ docker stack ps dcThis shows the details of each running task scheduled by services in your stack, similar to
service ps, but for each service in the stack. Notice that these containers have been scheduled across our swarm, not just on one node like Docker Compose did.
Conclusion
In this exercise, we stood up our first stack. A stack is a collection of docker components (services, networks, volumes, etc) that make up a full application, and we can create one directly from the same docker compose file we used to start an application on a single host using docker compose. A stack, however, will schedule workloads using Swarm, distributed across our cluster.