Last active
March 27, 2017 16:19
-
-
Save mcastelino/bcbf93c8416c416f494317af6ba14062 to your computer and use it in GitHub Desktop.
CC Swarm Demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Delete any old containers and services | |
sudo docker service ls | |
sudo docker service rm $(sudo docker service ls -q) | |
sudo docker rm -f $(sudo docker ps -a -q) | |
# Show you can just run containers with the "exact same CLI" | |
docker run -it debian | |
# Show that we are running with a different default runtime | |
systemctl status docker | |
#Needed only for the first time | |
docker swarm init | |
# Show the nodes that are currently present in the swarm | |
docker node ls | |
# Kick off a scaleable web server that responds back with the hostname of the actual container | |
# that is responding to the request | |
docker service create --name my_web --replicas 3 --publish 8080:80 nginx /bin/bash -c "hostname > /usr/share/nginx/html/hostname; nginx -g \"daemon off;\"" | |
# show that there are 3 containers each in its own qemu-kvm VM | |
sudo docker service ls | |
docker ps | |
ps auxw | grep qemu | |
# Kick off multiple queries, you should see responses from different hosts | |
curl 127.0.0.1:8080/hostname; curl 127.0.0.1:8080/hostname; curl 127.0.0.1:8080/hostname; curl 127.0.0.1:8080/hostname; | |
# show that there are 3 containers each in its own qemu-kvm VM | |
docker ps | |
ps auxw | grep qemu | |
# Now scale it up | |
docker service scale my_web=8 | |
# Show we have 8 containers | |
sudo docker service ls | |
# You will have 8 unique responses | |
curl 127.0.0.1:8080/hostname; curl 127.0.0.1:8080/hostname; curl 127.0.0.1:8080/hostname; curl 127.0.0.1:8080/hostname; | |
curl 127.0.0.1:8080/hostname; curl 127.0.0.1:8080/hostname; curl 127.0.0.1:8080/hostname; curl 127.0.0.1:8080/hostname; | |
# show that there are 8 containers each in its own qemu-kvm VM | |
docker ps | |
ps auxw | grep qemu | |
docker service remove my_web |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
systemctl status docker
and
systemctl status docker-cor