Home » Devops » Introduction To Linux Docker

What is Docker?

Docker is a open-source project which provides the isolated environment on top of the base primary Linux Operating System!. Yes, Docker is unlike Virtual Machines or chroot, it uses LXC (Linux Containers) to work on the base Linux operating system, Docker shares the base systems kernel with the isolated machine. May be you can think it gives the similar environment like chroot but it shows lot more isolation than chroot, lets take a quick look at Docker and LXC bellow. Docker versus LXC (Linux Containers) As the relation between Docker and LXC is outspoken, its important to list the features which are provided by LXC and Docker,

  • The base point of both LXC and Docker is to isolate the filesystem, the instance which is isolated from the base Operating System using Docker or LXC  is called as containers. All the containers which are created using either of tools have a separate root filesystem but same kernel.
  • The next points comes on isolating the resource for the containers, the behavior of Docker and LXC is identical in this case both allows to allocate the cpu and memory to each containers using base systems internal kernel feature called Cgroups.
  • Both Docker and LXC are alike to network isolation and interactive shell, in network isolation each containers are allocated with network namespace and virtual interface and ip address of its own. The other feature is interactive shell it provides pseudo-tty.
  • Docker root filesystem are created using copy-on-write, which makes deployment extremely fast, this basically provides by AUFS (AnotheUnionFS) a union filesystem Docker depends on. If you want the same feature to attache in LXC it requires you to install AUFS manually.
  • The other important point is about portability, changes in the filesystem can be committed and it can be spin into a new image and re used for multiple containers, In case of LXC manual configuration required, you need to have your hands into the configurations

How To install Docker in Linux?

Docker installation in Linux is straight forward. To install Docker in distros which has Debian based package manager follow the below steps.

$ sudo apt-get upadte

$ sudo apt-get install docker.io

$ sudo apt-key adv –keyserver hkp://keyserver.ubuntu.com:80 –recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9

$ sudo sh -c “echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list”

$ sudo apt-get update

$ sudo apt-get install lxc-docker

To install Docker in rpm based distros, it requires to get the EPEL repository set, you can follow this link to set up the repo. Once that is done just execute the below commands to install.

$ sudo yum -y install docker-io $ sudo -y update docker-io

How to start Docker container?

To get start with Docker container first we need to pull the image from Docker repo, then run Docker container. All the interaction with Docker system will be happening on root privilege with docker command.

To search for  Docker image.

$ sudo docker search ubuntu

To Download image for Docker index

$ sudo docker pull ubuntu

To check the image is pulled successfully, you can use this command, it also list all the images you have downloaded on your system.

$ sudo docker image

The output of the above command will be like this

To start Docker image which you download enter this command,

$ sudo docker run -i -t <IMAGE ID>

To start Docker in privileged mode enter the following command

$ sudo docker run –privileged -t -i <IMAGE ID>

To launch commands without starting  Docker

$ sudo docker run -t -i <IMAGE ID> /usr/bin/ls

That completes our introduction, try Docker and share your usability here and feel free to leave your comments.

Leave a Reply

Your email address will not be published. Required fields are marked *

CAPTCHA Image

*