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
Docker package is included in the default CentOS-Extras repository. So to install docker , simply run below yum command :
[root@localhost ~]# yum install docker
If you looking for stable and latest version Docker then you should go for Docker CE. Below are the steps how to install Docker CE.
Set the repository for Docker Community Edition
First install the required packages for setting up Docker Community edition repo using the following command
[root@localhost ~]# yum install yum-utils device-mapper-persistent-data lvm2 -y
Run the beneath command to set the stable repository of Docker CE (Community edition)
[root@localhost ~]# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
Now use the following yum command to install Docker CE.
[root@localhost ~]# yum install docker-ce -y
Verify the Docker Version using the beneath command
[root@localhost ~]# docker --version
Docker version 19.03.12, build 48a66213fe
OR
[root@testserver ~]# docker version
Client: Docker Engine - Community Version: 19.03.12 API version: 1.40 Go version: go1.13.10 Git commit: 48a66213fe Built: Mon Jun 22 15:46:54 2020 OS/Arch: linux/amd64 Experimental: false Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? [root@testserver ~]#
[root@localhost ~]#
Once the Installation is finished , start docker service and enable it at boot using below commands
[root@localhost ~]# systemctl start docker && systemctl enable docker
[root@testserver ~]# docker info
Client: Debug Mode: false Server: Containers: 0 Running: 0 Paused: 0 Stopped: 0 Images: 0 Server Version: 19.03.12 Storage Driver: overlay2 Backing Filesystem: xfs Supports d_type: true Native Overlay Diff: true Logging Driver: json-file Cgroup Driver: cgroupfs Plugins: Volume: local Network: bridge host ipvlan macvlan null overlay Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog Swarm: inactive Runtimes: runc Default Runtime: runc Init Binary: docker-init containerd version: 7ad184331fa3e55e52b890ea95e65ba581ae3429 runc version: dc9208a3303feef5b3839f4323d9beb36df0a9dd init version: fec3683 Security Options: seccomp Profile: default Kernel Version: 3.10.0-1127.18.2.el7.x86_64 Operating System: CentOS Linux 7 (Core) OSType: linux Architecture: x86_64 CPUs: 4 Total Memory: 1.777GiB Name: testserver.com ID: NHPO:AZ7D:UOYK:Z45F:DNLF:75FJ:MLTH:YIAE:7PD6:BJOL:R5DV:EUV6 Docker Root Dir: /var/lib/docker Debug Mode: false Registry: https://index.docker.io/v1/ Labels: Experimental: false Insecure Registries: 127.0.0.0/8 Live Restore Enabled: false
[root@testserver ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
[root@testserver ~]# docker pull centos
Using default tag: latest latest: Pulling from library/centos 6910e5a164f7: Pull complete Digest: sha256:4062bbdd1bb0801b0aa38e0f83dece70fb7a5e9bce223423a68de2d8b784b43b Status: Downloaded newer image for centos:latest docker.io/library/centos:latest [root@testserver ~]#
Verify CentOS images that have been fetched :
[root@testserver ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE ubuntu latest 1e4467b07108 2 weeks ago 73.9MB centos latest 831691599b88 7 weeks ago 215MB thanishinfotech/javagitmaven latest 73ae15627927 7 months ago 690MB [root@testserver ~]#
[root@localhost ~]# docker run -i -t centos /bin/bash
[root@dbf66395436d /]#
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 .
[root@cd05639b3f5c /]# cat /etc/redhat-release
CentOS Linux release 7.0.1406 (Core)
[root@cd05639b3f5c /]# exitexit
[root@localhost ~]#
We can also search Containers based on fedora & ubuntu OS.
[root@localhost ~]# docker search ubuntu
Display the list of running containers
The DevOps seminar will help you to learn DevOps from scracth to deep knowledge of various DevOps tools such as fallowing List.
  Kubernetes. />