In my last article I shared the steps to configure or build ceph storage cluster in Openstack. Now in this article I will share the steps to install docker on Linux and to configure thin provisioning storage for Docker, Now Docker is one of the most common container solution, but it’s not the only container solution.

  • Docker
  • Kubernetes, which is based on Google technology.
  • Mesos, that is coming from the Apache Foundation.

Tutorial: Install Docker on Linux ( CentOS / RHEL 7 )

Let us understand some more about these container solution


What is Docker?

  • Well, in Docker all applications and dependencies are packaged in one single binary, which is the container.
  • The way how you work with Docker closely resembles to GIT. You use docker push, docker pull, docker commit which closely looks like GIT commands that you are using to download something from GIT, to work with it, to upload something to GIT, and to commit changes if you want to.
  • The core of Docker is Docker image. Docker images are built upon immutable file system images. Docker hub, Docker registry, and Docker datacenter can be used for image storage
  • Image storage is very important in the Docker environment. And the way how you want to deal with it really depends on the level of scalability that is required in your environments. The easiest solution is to use Docker hub, which is all online. But if you need to run a lot of containers within your own datacenter, you can use Docker datacenter instead.
  • If you are running multiple containers and as your business starts to depend more and more on containers, you may need to implement Orchestration also. This happens by using external and often third-party solutions such as Marathon, SWARM, Kubernetes, and OpenShift.
  • Docker itself is a commercial solution that is offered by Docker, Inc. Recently, an open-source development version has been split off and made available through the Moby project.


What is Kubernetes?

  • Kubernetes was designed from scratch with Google Borg as the leading example and open-sourced in 2015
  • It is based on the Docker container image and it’s managed by CNCF instead of a single company.
  • Kubernetes container technology is independent of the underlying infrastructure and it offers a standard deployment interface regardless of the cloud vendor that is using it.
  • it has powerful tools for developers.


What is Mesos container technology?

  • Mesos was designed as a next generation cluster-manager.
  • It offers datacenter resources abstraction, which makes it cloud agnostic.
  • It also allows you to do colocation of different workloads. That means that you can run containerized and non-containerized workloads within the same environment.
  • Automates operations like deployment, self-healing, and scaling.
  • Providing High Availability fault-tolerant environment.
  • It provides exstensibility and it allows you to elastically scale.


Before we start with the steps to install Docker, we need to know a little bit about Docker terminology; otherwise, you will be so confused about the different components that you’ll be working with.

  • Container Image: It’s a full image that consists of multiple, read-only layers and only one writeable layer.
  • Base Image: The base image is a fresh operating system without additional layers, so it’s the lowest layer in the imaging in the Docker container image.
  • Image Layer: Each change to the base layer will result in a new layer that is stacked on the currently existing layers.
  • Container: A running instance of a container image
  • Docker Host: The host where the Docker containers are running
  • Docker Hub: The central Docker repository, that contains many ready-to-use container images.


Pre-requsites for Installation

  • 8 GB of RAM
  • 50 GB of Storage for container images
  • Optional storage for persistent volumes


Perform clean up

It is important that before starting with a fresh installation first you must make sure that there are no old versions available any more.

# yum remove docker docker-client docker-client-latest docker-common \
                  docker-latest docker-latest-logrotate docker-logrotate \
                  docker-selinux docker-engine-selinux docker-engine


Install Docker

Once the old docker content has been removed, we can install Docker packages. That starts with some dependencies which we install below

[[email protected] ~]# yum install -y yum-utils device-mapper-persistent-data lvm2

Next, we need to add a repository to install docker. We can do add a repo using yum-config-manager. Here CE stands for Community Edition. That is to distinguish between the free Community Edition and the Enterprise Edition that requires separate licensing.

[[email protected] ~]# yum-config-manager --add-repo
Loaded plugins: fastestmirror, langpacks
adding repo from:
grabbing file to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo

Next to install docker we need to run yum install docker-ce to actually install it

# yum install docker-ce

Now that the software has been installed, we can use systemctl enable docker to enable the Docker service.

[[email protected] ~]# systemctl enable docker
Created symlink from /etc/systemd/system/ to /usr/lib/systemd/system/docker.service.

As you see the status of docker service, it is showing that it is currently enabled, but not running; it’s marked as dead.

[[email protected] ~]# systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
   Active: inactive (dead)

So systemctl start docker is going to start the Docker backend service that is taking care of all of these containers.

[[email protected] ~]# systemctl start docker


Setup LVM thin provisioning

Next we need to take care of storage. In order to do so, we are going to create an LVM storage pool for the container images; and we will be using device mapper direct lvm.

Now we need a block device in this container storage. We need to create an LVM storage pool for the container images; and in order to so, we are using device mapper direct LVM.

[[email protected] ~]# pvs
  PV         VG     Fmt  Attr PSize  PFree
  /dev/sda2  centos lvm2 a--  <9.52g       0
  /dev/sdb1  centos lvm2 a--  <8.00g 1020.00m

To check the list of available partitions and devices on your system. As we see we have /dev/sdc as a free partition and is not used by our LVM. So we can use /dev/sdc as a physical volume.

[[email protected] ~]# ls -l /dev/sd*
brw-rw---- 1 root disk 8,  0 Dec 20 15:40 /dev/sda
brw-rw---- 1 root disk 8,  1 Dec 20 15:40 /dev/sda1
brw-rw---- 1 root disk 8,  2 Dec 20 15:40 /dev/sda2
brw-rw---- 1 root disk 8, 16 Dec 20 15:40 /dev/sdb
brw-rw---- 1 root disk 8, 17 Dec 20 15:40 /dev/sdb1
brw-rw---- 1 root disk 8, 32 Dec 20 15:40 /dev/sdc

We will create physical volume using pvcreate for /dev/sdc

[[email protected] ~]# pvcreate /dev/sdc
  Physical volume "/dev/sdc" successfully created.

Next create a volume group using the physical volume on /dev/sdc

[[email protected] ~]# vgcreate vg_docker /dev/sdc
Volume group "vg_docker" successfully created

Next create a logical volume with name “thinpool“. We create it under vg_docker volume group, and we allocate a size of 95% of the volume group.

[[email protected] ~]# lvcreate --wipesignatures y -n thinpool vg_docker -l 95%VG
  Logical volume "thinpool" created.

We also want to create an LVM volume with the name thinpoolmeta, which is used for the metadata.

[[email protected] ~]# lvcreate --wipesignatures y -n thinpoolmeta vg_docker -l 1%VG
  Logical volume "thinpoolmeta" created.
The reason we are separating this is so that we can allow for more efficient storage once we get to the Docker environment.

Next we change the logical volume layout using lvconvert, this is going to setup your thin storage pool, and a thin pool is exactly what you need to make the storage of the docker images as efficient as possible

[[email protected] ~]# lvconvert -y --zero n -c 512K --thinpool vg_docker/thinpool --poolmetadata vg_docker/thinpoolmeta
  Thin pool volume with chunk size 512.00 KiB can address at most 126.50 TiB of data.
  WARNING: Converting vg_docker/thinpool and vg_docker/thinpoolmeta to thin pool's data and metadata volumes with metadata wiping.
  Converted vg_docker/thinpool and vg_docker/thinpoolmeta to thin pool.
-y         -> Do not prompt for confirmation interactively but always assume the answer yes
--zero     -> For snapshots, this controls zeroing of the first 4KiB of data in the snapshot. If the LV is read-only, the snapshot will not be zeroed. For thin pools, this controls zeroing of provisioned blocks. Provisioning of large zeroed chunks negatively impacts performance.
-c         -> The size of chunks in a snapshot, cache pool or thin pool
--thinpool -> The name of a thin pool LV.

Next we are going to create configuration file, and we choose the name vg_docker_image.profile

[[email protected] ~]# cat /etc/lvm/profile/vg_docker_image.profile
activation {

These are the parameters that in the thin port storage pool will be used for automatically extending the thin storage.

Now we need to use vim to create the profile file.

You should make sure that this matches the name of the thinpool that you have created
[[email protected] ~]# cat /etc/lvm/profile/vg_docker-thinpool.profile
activation {

Now that we have created the profile for the thinpool that we are going to create, we can convert the LVM volume to a thin provisioned LVM volume

[[email protected] ~]# lvchange --metadataprofile vg_docker-thinpool vg_docker/thinpool
  Logical volume vg_docker/thinpool changed.
[[email protected] ~]# lvs
  LV       VG        Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root     centos    -wi-ao---- <15.78g
  swap     centos    -wi-ao---- 760.00m
  thinpool vg_docker twi-a-t---   7.59g             0.00   0.05

And there we can see that the logical volume has just changed. Now we need to create a Docker configuration file “daemon.json

[[email protected] ~]# cat /etc/docker/daemon.json
  "storage-driver": "devicemapper",
  "storage-opts": [
  • So the storage driver is set to devicemapper, which tells Docker that it should use the device mapper storage layer.
  • The storage options are specified as dm.thinpooldevice, which is the thinpool that it should be using;
  • And then we have the dm.use_deferred_removal=true and dm.use_deferred_deletion=true that need to be included in there as well.


With this we are done with the steps to install docker, now it’s a smart idea to restart docker. We have previously started it, but in the previous start it wasn’t using this thin provisioning.

[[email protected] ~]# systemctl restart docker

And now we can see that the Docker daemon is active and running.

[[email protected] ~]# 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 Thu 2018-12-20 15:51:20 IST; 57min ago
 Main PID: 2601 (dockerd)
    Tasks: 8
   Memory: 33.1M
   CGroup: /system.slice/docker.service
           └─2601 /usr/bin/dockerd -H unix://

Dec 20 15:51:20 dockerd[2601]: time="2018-12-20T15:51:20.567366488+05:30" level=info msg="Succ...pper
Dec 20 15:51:20 dockerd[2601]: time="2018-12-20T15:51:20.599102217+05:30" level=info msg="Grap...nds"
Dec 20 15:51:20 dockerd[2601]: time="2018-12-20T15:51:20.599562425+05:30" level=info msg="Load...rt."
Dec 20 15:51:20 dockerd[2601]: time="2018-12-20T15:51:20.676558617+05:30" level=info msg="Defa...ess"
Dec 20 15:51:20 dockerd[2601]: time="2018-12-20T15:51:20.706254085+05:30" level=info msg=""
Dec 20 15:51:20 dockerd[2601]: time="2018-12-20T15:51:20.723749710+05:30" level=info msg="Dock...09.0
Dec 20 15:51:20 dockerd[2601]: time="2018-12-20T15:51:20.723793675+05:30" level=info msg="Daem...ion"
Dec 20 15:51:20 dockerd[2601]: time="2018-12-20T15:51:20.725451405+05:30" level=warning msg="C...ATH"
Dec 20 15:51:20 systemd[1]: Started Docker Application Container Engine.
Dec 20 15:51:20 dockerd[2601]: time="2018-12-20T15:51:20.739026902+05:30" level=info msg="API ...ock"
Hint: Some lines were ellipsized, use -l to show in full.


Lastly I hope the steps from the article to install docker on Linux was helpful. So, let me know your suggestions and feedback using the comment section. In my next article I will share Tutorial: How to manage docker container with examples ?


Leave a Reply

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