Home » Docker » Docker installation and configuration

Docker installation and configuration

Docker is an open source platform for system admins and developers to create, ship, and run apportioned applications. Docker permits you to execute applications inside containers, it provide OS (Operating System) level virtualization on Linux. Docker is developed to process your applications faster. It basically use system resource isolation features of the Linux kernel such as cgroups and kernel namespaces to permit self-directed (independent) “containers” to run within a individual Linux instance, debarring the overhead of starting virtual machines.
Docker helps you to execute your applications separately from your infrastructure AND treat your infrastructure such as managed application. Docker helps you execute,test and deploy faster.

Linux kernel’s namespaces generally completely isolate an application’s view of the operating environment, including network, mounted file system , process trees, and user IDs, while cgroups provide resource isolation facility, such as CPU, memory, block I/O and network. Docker admits the libcontainer library for containers implementation, and builds on top of libvirt, Linux containers and systemd-nspawn, which provide interfaces facilities.

Easy deployment and scaling

Docker’s container-based platform permits highly portable workloads. Docker containers can run on a admin’s and developer’s local system, on physical or virtual machines in a data center, as well as in the Cloud.
Docker’s portability and lightweight features make roundly managing workloads easygoing. You can use Docker to promptly scale up or tear down applications and services.

Much workloads and higher density
Docker is a lightweight and fast application platform which provides a feasible, cost-effective alternate choice of hypervisor based virtual machines. This is specially useful in high density situation (environments) for instance, implementing own Cloud or Platform-as-a-Service. As well as also useful for small and medium deployments where you require to get more resources.

Docker components of:
The Docker Engine – It provide the lightweight and powerful open source container virtualization technology for your applications.
Docker Hub – It provide SaaS service for sharing and managing your application stacks.
Docker installation on centos 7
Docker by default included in the Centos 7 EPEL repository. You can install it by using following steps.

[root@notihost6 ~]# yum install docker

Selection_003
Selection_004
Installaing on Centos 6
To install docker on Centos 6 you have to enable EPEL repository by default it not enable on centos 6 so install EPEL rpm package from EPEL repository and then run the following command to install docker on centos 6

[root@notihost6 ~]# yum install docker-io

Once installation gets completed then execute the below command to start docker daemon.

[root@notihost6 ~]#service docker start

if you want start at boot, as below.

[root@notihost6 ~]#chkconfig docker on

Now verify that Docker is working or not. Get the latest centos image first as given below.

[root@notihost6 ~]# docker pull centos

Selection_005
Next make sure that image running or not:

[root@notihost6 ~]# docker images centos

The output should be as similar

[root@notihost6 ~]# docker images centos

Selection_006
Execute a simple bash shell to test the image:

[root@notihost6 ~]# docker run -i -t centos /bin/bash

Selection_007
If everything is working fine, you will get a simple command prompt. Type exit to continue.

Docker permits programmer to run applications inside containers. Execute the following command to run an application inside a container.

[root@notihost6 ~]# docker run centos /bin/echo ‘Hello My First Docker’
Hello My First Docker

The following command will show the container ID.

[root@notihost6 ~]# sudo docker run -d centos /bin/sh -c “while true; do echo hello world; sleep 1; done”

Selection_009
Docker ps command will shows the user information such as container id, name created data an time as well as status.

[root@notihost6 ~]# docker ps

Selection_010

docker logs shows the what’s going on

[root@notihost6 ~]# docker logs insane_tesla
MY First Docker Container

Run the following command to stop the container

[root@notihost6 ~]# docker stop insane_tesla

Now verify the status of container

[root@notihost6 ~]# docker ps

If output is blank that’s mean container has been stopped.

Run a Web Application in Docker
For instance we are going to run python web app inside docker container.

[root@notihost6 ~]# docker run -d -P training/webapp python app.py

Selection_011

Now verify the status of docker container using by following command.

[root@notihost6 ~]# docker ps -l

Selection_012

If you want to port mappings in Docker containers then use the following command.

[root@notihost6 ~]# docker run -d -p 5000:5000 training/webapp python app.py

Selection_014
The above command map port 5000 inside container to port 5000 on local host
Finally you can access your webapp through internet web browser using 5000 port as given below.
Selection_015

Ubuntu installation
Ubuntu-maintained Package Installation
To install the latest Ubuntu package (this is not the most recent Docker release):

[root@notihost6 ~]# sudo apt-get update
[root@notihost6 ~]# sudo apt-get install docker.io

Then enable docker command in bash profile.

[root@notihost6 ~]# source /etc/bash_completion.d/docker.io

That’s it Cheers!

About

I am founder and webmaster of www.linuxpcfix.com and working as a Sr. Linux Administrator (Expertise on Linux/Unix & Cloud Server) and have been in the industry since more than 14 years.

2 thoughts on “Docker installation and configuration

  1. Ashok says:

    Hi,

    documents is clear to install docker service in linux machine but you please let us know how can we use it for apache version to client.

    Thanks

Leave a Reply

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

*
*

Time limit is exhausted. Please reload the CAPTCHA.

Categorized Tag Cloud