This blog entry is a follow-up of my blog entry entitled “Step-by-Step Deployment of Docker on Eucalyptus 3.4 for the Cloud Administrator“. In that blog entry, I covered how to deploy an Ubuntu Raring Cloud Image on Eucalyptus, and use that image to deploy Docker. The really cool thing about Docker is that it provides the ability to deploy different operating systems within one machine – in this case, an instance. The focus of this entry is to show how to deploy a CentOS 6.5 image in a instance running Docker on Eucalyptus 3.4.
Prerequisites
The prerequisites for this blog is to complete the steps outlined in my previous blog about Docker on Eucalyptus 3.4. Once those steps are completed by the cloud administrator (i.e. a user associated with the ‘eucalyptus’ account), you can get started on the steps below. One thing to note here, to follow these steps, there is no need to be the cloud administrator. This entry is entirely directed to cloud users. Since Eucalyptus IAM is similar to AWS IAM, the following EC2 Actions need to be allowed for the cloud user:
- AuthorizeSecurityGroupIngress – to authorize SSH traffic in the security group the instance is using. Check out euca-authorize for more information.
- CreateKeyPair – to create a keypair to access the instance through SSH. Check out euca-create-keypair for more information.
- CreateSecurityGroup – (optional) if a security group is not specified when using euca-run-instances, the ‘default’ security group is used. For more information, check out euca-create-group.
- DescribeImages – to describe the Ubuntu Raring EMI provided by the cloud administrator. Check out euca-describe-images for additional information.
- DescribeInstances – to check the status of the recently launched instance. Refer to euca-describe-instances for additional information.
- RunInstances – to launch the instance. Check out euca-run-instances for additional information.
Instance Deployment
To get started, we need to launch the Ubuntu Raring EMI that has been provided by the cloud administrator. In this example, the EMI will be emi-26403979:
$ euca-describe-images emi-26403979 --region account1-user01@ IMAGE emi-26403979 ubuntu-raring-docker-rootfs-v3/ubuntu-raring-docker-v3.manifest.xml 441445882805 available private x86_64 machine eki-17093995 eri-6BF033EE instance-store paravirtualized
If the –region option seems confusing, this is due to the fact that I am using the nice configuration file feature in Euca2ools. Its really helpful when you are using different credentials for different users.
Now that we know the EMI we can use, lets launch the instance. We will be using the cloud-init config file from my previous Docker blog to configure the instance. The VM type used here is c1.xlarge. This is because I wanted to make sure I had 2 CPU, and 2 Gigs of RAM for my instance:
$ euca-run-instances -k account1-user01 -t c1.xlarge --user-data-file cloud-init-docker.config emi-26403979 --region account1-user01@ RESERVATION r-2EE941D4 961915002812 default INSTANCE i-503642D4 emi-26403979 euca-0-0-0-0.eucalyptus.euca-hasp.eucalyptus-systems.com euca-0-0-0-0.eucalyptus.internal pending account1-user01 0 c1.xlarge 2014-02-14T00:47:15.632Z LayinDaSmackDown eki-17093995 eri-6BF033EE monitoring-disabled 0.0.0.0 0.0.0.0 instance-store paravirtualized
Make sure the instance gets into the running state:
$ euca-describe-instances --region account1-user01@ RESERVATION r-2EE941D4 961915002812 default INSTANCE i-503642D4 emi-26403979 euca-10-104-7-10.eucalyptus.euca-hasp.eucalyptus-systems.com euca-172-17-112-207.eucalyptus.internal running account1-user01 0 c1.xlarge 2014-02-14T00:47:15.632Z LayinDaSmackDown eki-17093995 eri-6BF033EE monitoring-disabled 10.104.7.10 172.17.112.207 instance-store paravirtualized
Now thats in the running state, lets SSH into the instance to make sure its up and running:
$ ssh -i account1-user01.priv ubuntu@euca-10-104-7-10.eucalyptus.euca-hasp.eucalyptus-systems.com Welcome to Ubuntu 13.04 (GNU/Linux 3.8.0-33-generic x86_64) * Documentation: https://help.ubuntu.com/ System information as of Fri Feb 14 00:49:52 UTC 2014 System load: 0.21 Users logged in: 0 Usage of /: 21.8% of 4.80GB IP address for eth0: 172.17.112.207 Memory usage: 5% IP address for lxcbr0: 10.0.3.1 Swap usage: 0% IP address for docker0: 10.42.42.1 Processes: 85 Graph this data and manage this system at https://landscape.canonical.com/ Get cloud support with Ubuntu Advantage Cloud Guest: http://www.ubuntu.com/business/services/cloud Use Juju to deploy your cloud instances and workloads: https://juju.ubuntu.com/#cloud-raring Your Ubuntu release is not supported anymore. For upgrade information, please visit: http://www.ubuntu.com/releaseendoflife New release '13.10' available. Run 'do-release-upgrade' to upgrade to it. Last login: Tue Nov 19 00:48:23 2013 from odc-d-06-07.prc.eucalyptus-systems.com ubuntu@euca-172-17-112-207:~$
Now its time to prepare the instance to create your own base Docker CentOS 6.5 image.
Preparing the Instance
To prepare the instance to create the base image, install the following packages using apt-get:
ubuntu@euca-172-17-112-207:~$ sudo -s root@euca-172-17-112-207:~# apt-get install rinse perl rpm \ rpm2cpio libwww-perl liblwp-protocol-https-perl
After the packages finish installing, lets go ahead and mount the ephemeral storage on the instance as /tmp to give Docker extra space for building the base image:
root@euca-172-17-112-207:~# curl http://169.254.169.254/latest/meta-data/block-device-mapping/ephemeral0 sda2 root@euca-172-17-112-207:~# mount /dev/vda2 /tmp root@euca-172-17-112-207:~# df -ah Filesystem Size Used Avail Use% Mounted on /dev/vda1 4.8G 1.1G 3.5G 24% / proc 0 0 0 - /proc sysfs 0 0 0 - /sys none 4.0K 0 4.0K 0% /sys/fs/cgroup none 0 0 0 - /sys/fs/fuse/connections none 0 0 0 - /sys/kernel/debug none 0 0 0 - /sys/kernel/security udev 993M 8.0K 993M 1% /dev devpts 0 0 0 - /dev/pts tmpfs 201M 240K 201M 1% /run none 5.0M 0 5.0M 0% /run/lock none 1002M 0 1002M 0% /run/shm none 100M 0 100M 0% /run/user /dev/vda2 9.4G 150M 8.8G 2% /tmp root@euca-172-17-112-207:~# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT vda 253:0 0 15G 0 disk ├─vda1 253:1 0 5G 0 part / ├─vda2 253:2 0 9.5G 0 part /tmp └─vda3 253:3 0 512M 0 part
Next, download the mkimage-rinse.sh script from the Docker repository on Github:
root@euca-172-17-112-207:~# wget --no-check-certificate https://raw.github.com/dotcloud/docker/master/contrib/mkimage-rinse.sh root@euca-172-17-112-207:~# chmod 755 mkimage-rinse.sh
Now we are ready to build the CentOS 6.5 Base Image.
Building the CentOS Image
The only thing left to do is build the base image. Use mkimage-rinse.sh to build the CentOS 6.5 base image:
root@euca-172-17-112-207:~# ./mkimage-rinse.sh ubuntu/centos centos-6
After the installation is complete, test out the base image:
root@euca-172-17-112-207:~# docker run ubuntu/centos:6.5 cat /etc/centos-release CentOS release 6.5 (Final)
Now we have a CentOS 6.5 base image. The mkimage-rinse.sh script can also be used to install CentOS 5 base images as well. Instead of passing centos-6, just pass centos-5. For example, I have created a CentOS 5 base image in this instance as well. Below shows the output of the images added to Docker:
root@euca-172-17-112-207:~# docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE ubuntu/centos 5.10 06019bdea24b 2 minutes ago 123.8 MB ubuntu/centos 6.5 cd23a8442c8a 2 hours ago 127.3 MB root@euca-172-17-112-207:~# docker run ubuntu/centos:5.10 cat /etc/redhat-release CentOS release 5.10 (Final)
As you can see, Docker helps developers test their software across multiple Linux distributions. With Eucalyptus (just as in AWS), users can use the ephemeral nature of instances to quickly stand up this test environment in one instance.