Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Workshop syllabus

In this step we'll create a swarm cluster from two nodes. You should've received access to two nodes in AWS.

  1. SSH in to the first node: ssh -i docker_demo.pem ubuntu@IP1
  2. Figure out the internal IP address of the node: ifconfig and check the eth0 address (10.0....)
  3. Initialize the Swarm cluster: `docker swarm init --listen-addr INTERNAL_IP --advertise-addr INTERNAL_IP
  4. Open a new tab and SSH to the other node: ssh -i docker_demo.pem ubuntu@IP2
  5. Check the internal IP of that node: ifconfig and eth0
  6. Join to the cluster with the command the previous command printed out. Before executing the command, you need to the extend it with the --listen-addr and --advertise-addr parameters (using the internal IP of the second node): docker swarm join TOKEN --listen-addr 10.0.... --advertise-addr 10.0..... node1...
  7. Get back to the first node and verify the results: docker node ls

In this step we'll deploy Docker's example application on our cluster.

  1. On the manager node (first node) create an overlay network: docker network create --driver overlay workshop
  2. Start the redis: docker service create --name redis -p 6379:6379 --network workshop redis:alpine
  3. Check out what happened: docker service ls
  4. List tasks: docker service ps redis
  5. Jump the host which runs the container and check docker ps
  6. What happens if we kill the container: docker kill CONTAINER_ID
  7. Go back to the manager if needed and check what happened: docker service ps redis
  8. Create the voting frontend: docker service create --name vote --replicas 2 -p 5000:80 --network workshop ghoranyi/docker-example-vote
  9. We should see two tasks: docker service ps vote
  10. Check out in the browser: http://IP1:5000/
  11. If you vote, hit refresh a few times, you'll see it actually loadbalances between the containers.
  12. Start the postgres: docker service create --name db -p 5432:5432 --network workshop postgres
  13. Start the worker: docker service create --name worker --network workshop ghoranyi/docker-example-worker
  14. Start the result frontend: docker service create --name result -p 5001:80 --network workshop ghoranyi/docker-example-result
  15. Check out the results in the browser: http://IP1:5001/. Check also the other IP. Note the routing mesh, we have the container only on one host, still it loads from the other one as well
  16. Get the ID of the vote container from docker ps
  17. Open a shell in the container: docker exec -ti <ID> sh
  18. Install curl: apk update && apk add curl
  19. Check Docker networking, you can actually curl result: curl result
  20. Also, you might want to check ifconfig and nslookup result
  21. Get out from the container: exit
  22. Scale up the voting frontend: docker service scale vote=3
  23. See results: docker service ps vote

In this step, we'll a Vizceral and Packetbeat to our system to visualize how the traffic flows through our cluster. All commands should be executed on the manager node.

  1. Start the bacend container: docker service create --name vizdemo-backend -p 8080:8080 -p 8878:8878 -p 9200:9200 --network workshop ghoranyi/docker-intuition-backend. This is a fairly big container, so this might take a few minutes.
  2. Start the agent: docker service create --name docker-agent --mount source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind --mode global --network workshop ghoranyi/docker-agent
  3. Open the voting app again, vote a few times, check the results. (voting at port 5000, results are at port 5001)
  4. Open vizceral: http://IP1:8080. Click on eu-west-1.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment