How to install Docker on CentOS 7
Docker is an open-source tool that makes creating & managing Linux containers(LXC) easy. Containers are like lightweight VMs which can be started & stopped in milliseconds. Dockers help the system admin & coders to develop their application in a container and can further scale up to 1000 of nodes.
The main difference between container and VM(Virtual machine) is that dockers provide process based isolation , whereas VM provides full isolation of resources. Virtual machine takes a minute to start where as container can be started in a second or less than a second. Container uses the Kernel of host OS , whereas VM uses the separate Kernel.
One of the limitation of Docker is that it can be used only on 64bit hosts OS.
In this post we will discuss how to install docker in CentOS 7.x
Installation of Docker on CentOS 7
Docker package is included in the default CentOS-Extras repository. So to install docker , simply run below yum command :
[[email protected] ~]# yum install docker
Start the Docker Service
Once the Installation is finished , start docker service and enable it at boot using below commands
[[email protected] ~]# service docker start [[email protected] ~]# chkconfig docker on
Download the official Centos images Locally
[[email protected] ~]# docker pull centos Pulling repository centos 192178b11d36: Download complete 70441cac1ed5: Download complete ae0c2d0bdc10: Download complete 511136ea3c5a: Download complete 5b12ef8fd570: Download complete
Verify CentOS images that have been fetched :
[[email protected] ~]# docker images centos REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE centos centos5 192178b11d36 2 weeks ago 466.9 MB centos centos6 70441cac1ed5 2 weeks ago 215.8 MB centos centos7 ae0c2d0bdc10 2 weeks ago 224 MB centos latest ae0c2d0bdc10 2 weeks ago 224 MB
Run a Docker Container :
[[email protected] ~]# docker run -i -t centos /bin/bash [[email protected] /]#
As we can see centos container has been started and we got the bash shell. In docker command we have used options like ‘-i attaches stdin and stdout’ and ‘-t allocates a terminal or console’ . To disconnect from container type exit .
[[email protected] /]# cat /etc/redhat-release CentOS Linux release 7.0.1406 (Core) [[email protected] /]# exit exit [[email protected] ~]#
We can also search Containers based on fedora & ubuntu OS.
[[email protected] ~]# docker search ubuntu [[email protected] ~]# docker search fedora
Display the list of running containers