How To Install Docker & Docker-Compose On Centos 7

In the previous blogs posts , We have learnt how we can Setup Redash dashboards with the help of docker and docker compose.


So Let us understand the basics of Docker and the installation procedure of Docker and Docker compose.


What Is Docker?


Docker is an opensource platform for developing , Shipping and running applications.


We can significantly reduce the delay between writing the codes and running applications in Production environment.


Using docker , We can segregate the applications from the infrastructure , By doing so we can quickly deliver the applications.


What Is Docker Compose?


Docker compose is a tool for defining and running multi-container docker applications.


We will use YAML file to confgiure definitions for the applications and services.Once the compose file is ready , We can easily deploy and manage docker applications using the single file.


Docker compose is basically a three step process:


  • Define the application’s environment in Dockerfile
  • Define the services that will create an application in docker-compose.yml file so that they can run together in an isolated environments.
  • Then Run docker-compose up to start and run the applications 


Docker compose can perform the following actions:


  • Start , Stop and Rebuild the services
  • Check the status of the running applications
  • Stream log out of the running services
  • Running a one-off command on a service


Example of Docker compose file.


version: '3'
image: nginx
image: mysql
- "3306:3306"


What Is Docker Engine?


Docker Engine is an Client-server application which has 3 major components.


  • A docker daemon (the dockerd command) , which is a long running program , Also referred as a service
  • A REST API which specifies the interface that programs can use to communicate with daemons and run commands against it.
  • docker command , a command line tool , called as docker client.




Installing Docker Packages.


Docker engine can be installed in different ways.


a)Setup Docker repository on the system and install using it.


b)Download the RPM package and installing packages manually.


Make sure you have sudo or root privileges to execute the following commands.


First we need to install yum-config-manager utility ,


sudo yum install yum-utils -y


Lets add the Docker repository to the system, Using the below command.


sudo yum-config-manager --add-repo



Lets go ahead and install the latest version of Docker engine and containerd packages ,


sudo yum install docker-ce docker-ce-cli


After the packages are installed , We can start the Docker service.


The above installation will create a systemd unit file using which we can manage the Docker service.


cat /usr/lib/systemd/system/docker.service



Start and Enable the Docker service using the below commands.


systemctl start docker


systemctl enable docker


To check the status of the docker , Run the below command.


systemctl status docker



We can check the version of docker engine installed.


sudo docker --version



If you wish to install the specific version of docker engine from the repository.First list the available versions in the repo and then we will install the specific version of docker.


yum list docker-ce --showduplicates | sort -r



To install the specific version , Use can select the version string from the second column.


For example : 17.12.1.ce-1.el7.centos


Lets install the above mentioned version using the below command.


sudo yum install docker-ce-17.12.1.ce-1.el7.centos


If you are installing custom version of docker and If the docker is already present on the system , The above commands with either Upgrade or Downgrade the docker version depending on the currently installed version of Docker.


Once installation is completed, Check the docker service and enable it to run on system boot.


Installing Docker Compose


Docker compose relies on docker engine , So make sure docker engine is installed on the system , either on local or remote.


Lets install the docker compose on the Centos system.


Run the below command to download the current stable release of Docker compose.


sudo curl -L "$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose


Apply the executable permission for the binary file which we have downloaded.


chmod +x /usr/local/bin/docker-compose


If the docker compose is installed on a different location For example: /usr/local/bin/ , You can copy the executable to /usr/bin directory.


You can check the version of docker-compose using the below command.


docker-compose --version





We have understood the basics of docker and we have learnt how to install docker engine and docker compose on the Centos operating system.


Hope you find it helpful.Please do check out my other publications.