Docker is a tool which quickly lets you to create light weight VMS with your code and deploy it as fast as possible through different services in various containers. Docker consists of various type of Containers (Docker VM’s) and Docker Hub (Online Docker’s VM sharing service). From within docker we see whole system but from base machine we just see one process running for each docker instance. There is a very smooth way of working inside Docker containers in which a system is built in such a way that developers, testers and Administrators can work together to deploy a code in faster way.
Add the EPEL Repository
Docker is part of Extra Packages for Enterprise Linux (EPEL), which is a community repository of non-standard packages for the RHEL distribution. First, we’ll install the EPEL repository:
# rpm -iUvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
Then, as a matter of best practice, we’ll update our packages:
# yum update -y
Installation
Now let’s install Docker by installing the docker-io package on centos6:
# yum install docker-io -y
Once the installation completes, we’ll need to start the Docker daemon:
# /etc/init.d/docker start
And finally, lets add Docker to start when the server boots:
# chkconfig docker on
Download a Docker Container
Let’s begin using Docker! Download the ubuntu Docker Container:
# docker pull ubuntu
Run a Docker Container
Now, to setup a basic ubuntu container with a bash shell, we just run one command. docker run will run a command in a new container, -i attaches stdin and stdout, -t allocates a tty, and we’re using the standard ubuntu container.
# docker run -it ubuntu /bin/bash
Yup.!! You are inside container, now you can use shell to pass the commends.
To Exit from the container, you need to enter “exit” comment.
Note: Inside container, you always logged in as a root user.
There are many community containers already available, which can be found through a search. In the command below I am searching for the keyword centos:
# docker search Ubuntu