Sunday, September 29, 2013

Try CoreOS and Docker at Futuregrid

Docker and CoreOS are interesting new software. You can try them on FutureGrid.

Before you try this, you need to have your FutureGrid account, of course, and should know how to use OpenStack at FutureGrid. Here's the link --> http://manual.futuregrid.org/openstackgrizzly.html

First, login to sierra and setup your OpenStack environment.
ssh username@sierra.futuregrid.org
module load novaclient
source .futuregrid/novarc

Boot an instance with CoreOS image.
nova boot coreos1 --flavor m1.small --image futuregrid/coreos --key_name keyname

Check the status of the instance with "nova list", and if it's "ACTIVE", login to the instance
ssh -i /path/to/your/pub-key core@10.35.23.119
Warning: Permanently added '10.35.23.119' (RSA) to the list of known hosts.
   ______                ____  _____
  / ____/___  ________  / __ \/ ___/
 / /   / __ \/ ___/ _ \/ / / /\__ \
/ /___/ /_/ / /  /  __/ /_/ /___/ /
\____/\____/_/   \___/\____//____/
core@coreos1 ~ $

Execute "echo Hello World!" inside a container.
docker run base /bin/echo Hello World!
Unable to find image 'base' (tag: latest) locally
Pulling repository base
b750fe79269d: Download complete
27cf78414709: Download complete
Hello World!

What it does is, 1. download the "base" image, 2. execute "echo Hello World!". The downloading process only happens at the first time. So if you execute "docker run base /bin/echo Hello World!" again, you can see what I meant.

Next, you can login to a container with this.
docker run -i -t base /bin/bash

If you check the OS with "lsb_release -a", you can find the base image is Ubuntu 12.10.
root@d7a0470c0e16:/# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 12.10
Release: 12.10
Codename: quantal
root@d7a0470c0e16:/# exit
exit
core@coreos1 ~ $ 

Next, execute a command in the background.
docker run -i -t -d base /bin/ping www.google.com
81e7918c9724

You can see the status of the container with this.
docker ps
ID                  IMAGE               COMMAND                CREATED             STATUS              PORTS
81e7918c9724        base:latest         /bin/ping www.google   41 seconds ago      Up 40 seconds

Take a look at the container.
docker logs 81e7918c9724
PING www.google.com (74.125.224.211) 56(84) bytes of data.
64 bytes from lax02s02-in-f19.1e100.net (74.125.224.211): icmp_req=1 ttl=53 time=9.96 ms
64 bytes from lax02s02-in-f19.1e100.net (74.125.224.211): icmp_req=2 ttl=53 time=9.97 ms
64 bytes from lax02s02-in-f19.1e100.net (74.125.224.211): icmp_req=3 ttl=53 time=10.0 ms
64 bytes from lax02s02-in-f19.1e100.net (74.125.224.211): icmp_req=4 ttl=53 time=9.95 ms
64 bytes from lax02s02-in-f19.1e100.net (74.125.224.211): icmp_req=5 ttl=53 time=10.0 ms
64 bytes from lax02s02-in-f19.1e100.net (74.125.224.211): icmp_req=6 ttl=53 time=9.96 ms
64 bytes from lax02s02-in-f19.1e100.net (74.125.224.211): icmp_req=7 ttl=53 time=9.95 ms

You can attach to the container with this.
docker attach 81e7918c9724
* When you want to detach, press "Ctrl-p" and "Ctrl-q".

Terminate the command.
docker kill 81e7918c9724
docker ps

So, now you think your container is gone, but actually what you did is stored. You can see the list with this.
docker ps -a -notrunc
ID                                                                 IMAGE               COMMAND                    CREATED             STATUS              PORTS
1c94ff1e5c6a180c525e7dc709e59d3f5275d38bcfbc057862eeb3ce8821e1e8   base:latest         /bin/ping www.google.com   13 minutes ago      Exit 0
64cf0b3a9f6b30bf794f312ec72596a7bb3b465dc2d93c1513228ecee8da3238   base:latest         /bin/bash                  24 minutes ago      Exit 0
a5000a2ba33503775eab2e0740b906971e29abad87d934d48efff6c6ab061fcd   base:latest         /bin/echo Hello World!     37 minutes ago      Exit 0

You can delete one with "docker rm <ID>" like this.
docker rm 1c94ff1e5c6a180c525e7dc709e59d3f5275d38bcfbc057862eeb3ce8821e1e8
docker ps -a -notrunc

Also, if you commit one of them, it will be saved as an image.
docker commit -m "My first container" 1c94ff1e5c6a180c525e7dc709e59d3f5275d38bcfbc057862eeb3ce8821e1e8 username/first_container

So, now you have your first custom image on the list. Means that you can install software packages, add something more as needed, commit the change, and execute a command or run a daemon very quickly. It's all done inside the container!
docker images
REPOSITORY                TAG                 ID                  CREATED             SIZE
username/first_container   latest              40cd6f5b996e        12 seconds ago      16.39 kB (virtual 180.1 MB)
base                      latest              b750fe79269d        6 months ago        24.65 kB (virtual 180.1 MB)
base                      ubuntu-12.10        b750fe79269d        6 months ago        24.65 kB (virtual 180.1 MB)
base                      ubuntu-quantal      b750fe79269d        6 months ago        24.65 kB (virtual 180.1 MB)
base                      ubuntu-quantl       b750fe79269d        6 months ago        24.65 kB (virtual 180.1 MB)


...So, with using Docker, you can build and train your system as a container and save it like a file very quickly. (Docker only overwrites the differences from the base image and save it in "/var/lib/docker/containers/", which is why it's so quick.) Also, the great thing about Docker is you can share your image on https://index.docker.io/.

One more interesting thing to say here is, the CoreOS is based on Google’s ChromeOS that automatically updates. So CoreOS is like a ChromeOS on the Cloud, but it's, of course, more than that. To my knowledge, the idea of CoreOS is to build your massive cluster on the Cloud as easily and quickly as possible.

I'll do more research about them. So please keep checking this blog. Thanks!

For more information:

No comments:

Post a Comment

Questions? Thoughts? We'd like to hear from you.