Follow

Using Docker in Ignite: Example Configuration

This article describes an example configuration of Docker 1.12 in Ignite.

  1. Create three instances from the "CentOS 7 - Docker CS Engine 1.12" template: swarm-manager, swarm-worker-1, and swarm-worker-2
  2. Update the hostnames on the instances: hostnamectl set-hostname swarm-manager --static && reboot (change hostname to swarm-worker-1 and swarm-worker-2 for the other instances)
  3. On swarm-manager, run:
    • docker swarm init: The swarm should successfully initialize, and the IP and token should be listed
    • docker node ls: The swarm manager should be listed
  4. On each swarm worker, run docker swarm join --token <token from previous step> <ip from previous step>:2377
  5. On swarm-manager, run docker node ls. It should now list the worker nodes and the swarm manager
  6. On swarm-manager, run docker run -d --restart always --name visualizer -p 8080:8080 -e HOST=$(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) -v /var/run/docker.sock:/var/run/docker.sock dockersamples/visualizer
    • Navigate in a web browser to <swarm manager ip>:8080. It should load and show the manager and both workers
  7. On the swarm-manager, create a volume with an application:
    • docker volume create --driver cloudistics --name my-website
    • docker run -it --rm --name cloudistics-configure -v my-website:/data --volume-driver cloudistics busybox sh
    • (inside the container, where previous command lands you): vi /data/index.html then type i to edit the file
    • Paste the following code in:
      <html>
      <head>
      <title>Hello world!</title>
      <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700' rel='stylesheet' type='text/css'>
      <style>
      body {
      background-color: white;
      text-align: center;
      padding: 50px;
      font-family: "Open Sans","Helvetica Neue",Helvetica,Arial,sans-serif;
      }
      #logo {
      margin-bottom: 40px;
      }
      </style>
      </head>
      <body>
      <img id="logo" src="http://www.iatechexpo.com/images/logo_cloudistics.png" />
      <h1>Docker 1.12 powered by the Ignite Platform</h1>
      </body>
      </html>
    • Press ESC and type :wq to save the changes and close the file
    • Exit the container (type exit)
  8. On the swarm-manager, create a second volume with an application:
    • docker volume create --driver cloudistics --name my-website2
    • docker run -it --rm --name cloudistics-configure -v my-website2:/data --volume-driver cloudistics busybox sh
    • (inside the container, where previous command lands you): vi /data/index.html
      then type i to edit the file
    • Paste in the code from the previous step
    • Press ESC and type :wq to save the changes and close the file
    • Exit the container (type exit)
  9. Create and remove a third volume on swarm-manager:
    • docker volume create --driver cloudistics --name my-website3
    • docker volume rm my-website3
  10. On swarm-manager, launch the web application service for the first volume:
    • docker service create --name my-app --mount type=volume,target=/usr/share/nginx/html,source=my-website,volume-driver=cloudistics --publish 8081:80 --constraint 'node.role == worker' nginx:latest nginx -g 'daemon off;'
    • In the visualizer, the container should be scheduled on the cluster
    • In a browser, navigate to <swarm-worker ip>:8081 to view the container
  11. On swarm-manager, launch the web application service for the second volume:
    • docker service create --name my-app2 --mount type=volume,target=/usr/share/nginx/html,source=my-website2,volume-driver=cloudistics --publish 8082:80 --constraint 'node.role == worker' nginx:latest nginx -g 'daemon off;'
    • In the visualizer, the container should be scheduled on the cluster
    • In a browser, navigate to <swarm-worker ip>:8082 to view the container
  12. On the manager node: docker node ls, then docker node update --availability drain swarm-worker-1
    • In the visualizer, the node should show it's draining, and the container should move to swarm-worker-2
    • On the manager node: docker node update --availability active swarm-worker-1
    • In the visualizer the node should show it's reactivated
  13. On the manager node: docker node ls, then docker node update --availability drain swarm-worker-2
    • In the visualizer, the node should show it's draining, and the containers should move to swarm-worker-1
    • On the manager node: docker node update --availability active swarm-worker-2
    • In the visualizer, the node should show it's reactivated
  14. Kill a worker node to show failover:
    • Shut down swarm-worker-1 (the worker node with the containers)
    • In the visualizer, docker should reschedule the containers
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments