Skip to content

Instantly share code, notes, and snippets.

@mcastelino
Last active March 4, 2017 00:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcastelino/e606cb3a01db79ba374d3bc1c8311b11 to your computer and use it in GitHub Desktop.
Save mcastelino/e606cb3a01db79ba374d3bc1c8311b11 to your computer and use it in GitHub Desktop.
Clear Containers Hands On

Clear Containers Hands On

For people in the meetup to try the Clear Containers hands on exercise on their own

Setup

You can try the hands on either in a VM using ciao-down or directly on your host system

Using ciao-down

First setup a clear containers virtual machine on Ubuntu/fedora using the instructions here https://github.com/01org/cc-oci-runtime/blob/master/documentation/Quickstart-Clear-Containers-in-a-Ubuntu-VM.md

Setup your host system

If you want to try clear containers on bare metal, you choose to directly install clear containers on your host system directly

Ubuntu: https://github.com/01org/cc-oci-runtime/blob/master/documentation/Installing-Clear-Containers-on-Ubuntu.md Centos: https://github.com/01org/cc-oci-runtime/blob/master/documentation/Installing-Clear-Containers-on-Centos-7.md

Setup terminals

Then setup three connections into the virtual machine

  • Open 3 terminal sessions
  • ciao-down connect or ssh in all three of these terminals will get you inside the VM

Demo 1. Showing inter connectivity between two clear containers

  1. Check that clear containers has been installed.

    systemctl status docker
    

    This will show you default runtime is cor. Which the clear container runtime

  2. In Terminal 1, run an alpine continer

    docker run -it alpine sh
    
  3. In terminal 2, run a debian container

    docker run -it debian bash
    
  4. Get the IP Addresses of each container in the terminal

    ip a
    
  5. Ping one container from the other

  6. On terminal 3

    ps auxw | grep qemu
    

    This will give you all the details of the qemu invocation

  7. On terminal 3

    docker network inspect bridge
    

This will give you the IP and MACs as docker setup for these containers. They will match the information you saw in step 3

  1. Cleanup

Exit from containers in terminal 1 and 2 using exit

Demo 2: Scaling ngnix using docker swarm and clear containers

  1. In Terminal 1

    docker swarm init
    docker service create --name testswarm --replicas 1 --publish 8080:80 nginx /bin/bash -c "hostname > /usr/share/nginx/html/hostname; nginx -g \"daemon off;\""
    docker service ls
    

Note: Wait till the service is up and running

  1. In terminal 2

    unset http_proxy
    curl 127.0.0.1:8080/hostname
    curl 127.0.0.1:8080/hostname
    curl 127.0.0.1:8080/hostname
    

    You will see the same hostname reported back from the service

  2. In terminal 1

    docker service scale testswarm=3
    docker service ls
    

Note: Wait till service ls show all replicas up and running

  1. In terminal 2

    curl 127.0.0.1:8080/hostname
    curl 127.0.0.1:8080/hostname
    curl 127.0.0.1:8080/hostname
    

    Now you will see 3 different hostnames as the load gets balanced across the three replicas

    You can scale it up more and see this continue

  2. Inspect the service

    docker service inspect
    
  3. To cleanup

    docker swarm leave --force
    

Note: If the swarm exercise does not work downgrade docker to 1.12.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment