A. Basic Concept of docker
Docker is a platform for developers and sysadmins to develop, deploy, and run applications with containers. The use of Linux containers to deploy applications is called containerization. Containers are not new, but their use for easily deploying applications is.
Containerization is increasingly popular because containers are:
- Flexible: Even the most complex applications can be containerized.
- Lightweight: Containers leverage and share the host kernel.
- Interchangeable: You can deploy updates and upgrades on-the-fly.
- Portable: You can build locally, deploy to the cloud, and run anywhere.
- Scalable: You can increase and automatically distribute container replicas.
- Stackable: You can stack services vertically and on-the-fly.
Images and containers
A container is launched by running an image. An image is an executable package that includes everything needed to run an application–the code, a runtime, libraries, environment variables, and configuration files.
A container is a runtime instance of an image–what the image becomes in memory when executed (that is, an image with state, or a user process). You can see a list of your running containers with the command, docker ps
, just as you would in Linux.
Containers and virtual machines
A container runs natively on Linux and shares the kernel of the host machine with other containers. It runs a discrete process, taking no more memory than any other executable, making it lightweight.
By contrast, a virtual machine (VM) runs a full-blown “guest” operating system with virtual access to host resources through a hypervisor. In general, VMs provide an environment with more resources than most applications need.
B.Installation of Docker
Step 1:-Let me install device mapper for docker
Device Mapper is a kernel-based framework that underpins many advanced volume management technologies on Linux. Docker’s devicemapper
storage driver leverages the thin provisioning and snapshotting capabilities of this framework for image and container management. This article refers to the Device Mapper storage driver as devicemapper
, and the kernel framework as Device Mapper
.
For the systems where it is supported, devicemapper
support is included in the Linux kernel. However, specific configuration is required to use it with Docker. For instance, on a stock installation of RHEL or CentOS, Docker defaults to overlay
, which is not a supported configuration.
The devicemapper
driver uses block devices dedicated to Docker and operates at the block level, rather than the file level. These devices can be extended by adding physical storage to your Docker host, and they perform better than using a filesystem at the level of the operating system.
[root@debasiseric1 ~]# yum install -y yum-utils device-mapper-persistent-data lvm2
Step 2:-Configure the repository for docker
[root@debasiseric1 ~]#yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
[root@debasiseric1 ~]#yum update
step 3:-Installation of docker CE
[root@debasiseric1 ~]# yum install docker-ce
STEP 3:-Enable,start and check status of docker
[root@debasiseric1 ~]# systemctl enable docker [root@debasiseric1 ~]# systemctl start docker [root@debasiseric1 ~]# systemctl status docker ● docker.service - Docker Application Container Engine Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled) Active: active (running) since Sat 2018-04-07 07:33:47 UTC; 21s ago Docs: https://docs.docker.com Main PID: 2560 (dockerd) CGroup: /system.slice/docker.service ├─2560 /usr/bin/dockerd └─2564 docker-containerd --config /var/run/docker/containerd/containerd.toml
Apr 07 07:33:46 debasiseric1.mylabserver.com dockerd[2560]: time=”2018-04-07T07:33:46.343240219Z” level=info msg=”devmapper: Creating filesystem xfs on device docker-202:1-50602726-ba…2726-base]”
Apr 07 07:33:46 debasiseric1.mylabserver.com dockerd[2560]: time=”2018-04-07T07:33:46.453252654Z” level=info msg=”devmapper: Successfully created filesystem xfs on device docker-202:1…02726-base”
Apr 07 07:33:46 debasiseric1.mylabserver.com dockerd[2560]: time=”2018-04-07T07:33:46.642080401Z” level=info msg=”Graph migration to content-addressability took 0.00 seconds”
Apr 07 07:33:46 debasiseric1.mylabserver.com dockerd[2560]: time=”2018-04-07T07:33:46.642802165Z” level=info msg=”Loading containers: start.”
Apr 07 07:33:47 debasiseric1.mylabserver.com dockerd[2560]: time=”2018-04-07T07:33:47.185425888Z” level=info msg=”Default bridge (docker0) is assigned with an IP address 172.17.0.0/16…IP address”
Apr 07 07:33:47 debasiseric1.mylabserver.com dockerd[2560]: time=”2018-04-07T07:33:47.331338927Z” level=info msg=”Loading containers: done.”
Apr 07 07:33:47 debasiseric1.mylabserver.com dockerd[2560]: time=”2018-04-07T07:33:47.388427809Z” level=info msg=”Docker daemon” commit=0520e24 graphdriver(s)=devicemapper version=18.03.0-ce
Apr 07 07:33:47 debasiseric1.mylabserver.com dockerd[2560]: time=”2018-04-07T07:33:47.388608540Z” level=info msg=”Daemon has completed initialization”
Apr 07 07:33:47 debasiseric1.mylabserver.com dockerd[2560]: time=”2018-04-07T07:33:47.408123750Z” level=info msg=”API listen on /var/run/docker.sock”
Apr 07 07:33:47 debasiseric1.mylabserver.com systemd[1]: Started Docker Application Container Engine.
Hint: Some lines were ellipsized, use -l to show in full.
[root@debasiseric1 ~]# docker images