Thursday, September 11, 2014

Docker : Container Technology

Hi,

This is on the new technology that i listened from someone and that makes some curiosity inside me.

After some search and digging on Google then i found some basic informations. Those information that i want to share with all blogger readers guys.

First is, What is Docker?
Why its required?
Why it's different from VM?
Then How can i use it in my activity?

Huuuu... Many questions..... :)

Lets start to know each and every question with their some basic information...

Now, Question 1: What is Docker?
Ans: Docker is basically a new container technology where developers or admin team can manage the application component with their desired versions in one place that says as container, after that they are able to ship that container at any place or say any machine without affecting machines configurations.

Or in Nutshell
providing an additional layer of abstraction and automation of operating system–level virtualization.

Question 2:  Why its required?
Ans: I thing previous ans is self explanatory for this one.
In further, With Docker, developers can build any app in any language using any tool chain. “Dockerized” apps are completely portable and can run anywhere.

Question 3:  Why it's different from VM(Virtual Machine)?
Ans:  
Virtual Machine: Each virtualized application includes not only the application - which may be only 10s of MB - and the necessary binaries and libraries, but also an entire guest operating system - which may weigh 10s of GB.

Docker: The Docker Engine container comprises just the application and its dependencies. It runs as an isolated process in userspace on the host operating system, sharing the kernel with other containers. Thus, it enjoys the resource isolation and allocation benefits of VMs but is much more portable and efficient.

Question: Then How can i use it in my activity?
Ans: I try to put some basic information on:
How to install it on your machine?
What are the basic command to use the docker?


INSTALLATION Process

Installation of the Docker in ubuntu 14.04 :

# sudo apt-get update

# sudo apt-get install docker.io

# sudo ln -sf /usr/bin/docker.io /usr/local/bin/docker

# sudo sed -i '$acomplete -F _docker docker' /etc/bash_completion.d/docker.io

# sudo docker run -i -t ubuntu /bin/bash

Above command will take you in bash prompt, where you can install the software/application that you want in the container.

Update the container package list:
# apt-get update
# apt-get install apache2   // install the apache2 in your container
# apt-get install mysql-server mysql-client
//install the mysql-server and mysql-client

# apt-get install php5 php5-mysql libapache2-mod-php5
// install php on the container

To exit from the docker:
# exit 
//It will take out you from docker prompt.

If you want to have particular distribution then use:
# docker run -i -t ubuntu:12.04 /bin/bash
It will create the ubuntu12.04 container.



Basic Command to get the docker information:

1. To know the docker version
# docker version

2. To search the specific docker image
docker search <image-name>
EX:
# docker search tutorial

3. To download the docker specific container image
docker pull <username>/<repo-name>
EX:
# docker pull tarunsinghal/lampstack

4. To run the docker container with the some output
docker run <username>/<repo-name> echo "Hello Tarun"
EX:
# docker run tarunsinghal/lampstack echo "Hello Tarun"

5. To run the any install in docker container
docker run <username>/<repo-name> apt-get install -y ping
EX:
# docker run tarunsinghal/lampstack apt-get install -y ping

6. To commit the docker images changes
docker commit <id> <username>/<repo-name>
EX:
# docker  commit 6789 tarunsinghal/lampstack 

Here,  id: is the docker id which will be identified by the
# docker ps -a   // that shows you number of container with their ids.
if you pass ids starting 4 character then thats enough to identify the right container.

7. To run the docker installed utility
docker run <username>/<repo-name> ping google.com
EX:
# docker run tarunsinghal/lampstack ping google.com

8. To know the running docker information with specific id.
# docker ps -a  // will tell you the running docker(s)
# docker inspect <id-number>  // will give you complete information on this docker ids

here, id : is the docker container id number

9. To push the new image in the docker registry
# docker push <username>/<repo-name>

In this way, you downloaded the docker with given repo, after that you make some changes and push it again to the docker registry with new name.

Now, that new docker images will be usable in any other similar environment.

10. If you want docker will automatically on when you boot your machine
# docker chkconfig docker on

Further more, if you want to know on this you can refer the below URL for Docker:  https://www.docker.com

No comments :