Home » DevOps » Docker » Docker Install on CentOS Example

About Suresh Kumar

Suresh Kumar
He holds a Master's degree in Computer Applications from the University of Madras. He is a Senior Solution Architect with over 20 years of experience in Java, J2ee, .Net, Mobile, Cloud and DevOps Technologies. He is actively involved in all the project phases (Pre-Sales and Post-Sales, Initiation, Configuration Management, Planning, Design, Architecting, Tracking and Monitoring, Scheduling, Testing, Estimation, Closure, Delivery) in his Projects. He holds experience in Banking, E-Commerce, Travels, Finance, Automobiles, Insurance, Services domains. He has implemented various methodologies ( Waterfall, Spiral, Agile Scrum, Kanban) in his projects. He is a Sun Certified Java Programmer, Sun Certified Java Web Component Developer, Sun Certified Java Architect, Microsoft Certified Visual Studio & TFS Administrator, and PMI Certified PMP. He is currently working as a Senior Solution Architect in Indian Government Project using Angular 8, ESRI ArcGIS, JSF PrimeFaces, Spring, Restful web services, PostgreSQL, MongoDB.

Docker Install on CentOS Example

With this example, we are going to demonstrate how to install the Docker on CentOS?

 

1. What is Docker?

Docker is a platform used to develop, deploy, and run applications by using containers. Docker consists of:

  • Docker Engine – lightweight and powerful open source containerization technology combined with a workflow for building and containerizing your applications.
  • Docker Hub – SaaS (Software as a Service) service for sharing and managing your application stacks.

2. What is CentOS?

CentOS stands for Community Enterprise Operating System. It is an open-source Linux distribution that provides a free, enterprise-class, community-supported computing platform functionally compatible with its upstream source, Red Hat Enterprise Linux (RHEL). The latest Version of CentOS now is 7.0. It is widely used by the System Administrators, DevOps Engineers, and Software Professionals. It is also used by many organizations for the Development and Production Servers.

3. Steps for Installation of Docker on CentOS

To complete the Installation of Docker on CentOS, It involves two steps:

  1. Install CentOS
  2. Install Docker on CentOS

4. Installation of CentOS

I am using my laptop containing Microsoft Windows 10 Pro Operating System for explaining “Docker Install on CentOS Example”

How to install CentOS on a machine containing Microsoft Windows 10 Pro Operating System and Version: 10.0.17763?

To accomplish this task, Understand the concept of Virtual Machine.

4.1 What is a Virtual Machine?

A Virtual Machine (VM) is a software program or operating system that not only exhibits the behavior of a separate computer but is also capable of performing tasks such as running applications and programs like a separate computer. A virtual machine, usually known as a guest (for this example, Virtual machine contains CentOS) is created within another computing environment referred to as a “host” (in my case, the host is Microsoft Windows 10 Pro Operating System). Multiple virtual machines can exist within a single host at one time. Virtual machines are becoming more common with the evolution of virtualization technology.

Virtual machines are computers whose hardware components are emulated by the host computer. A virtual machine is also known as a guest.

The following are free Virtual Machine Software available :

I am going to explain this Docker Install on CentOS example by installing Oracle VM VirtualBox on Microsoft Windows 10 Pro and Version: 10.0.17763.

4.2 What is Oracle VM Virtual Box?

Oracle VM VirtualBox is a free, open source, cross-platform application for creating, managing and running virtual machines (VMs).
Oracle VirtualBox enables you to set up one or more virtual machines (VMs) on a single physical machine, and use them simultaneously, along with the actual machine. Each virtual machine can execute its own operating system, including versions of Microsoft Windows, Linux, BSD, and MS-DOS.

VirtualBox runs on Windows, Linux, Macintosh, and Solaris hosts and supports a large number of guest operating systems including but not limited to Windows (NT 4.0, 2000, XP, Server 2003, Vista, Windows 7, Windows 8, Windows 10), DOS/Windows 3.x, Linux (2.4, 2.6, 3.x and 4.x), Solaris and OpenSolaris, OS/2, and OpenBSD.

4.3 Installation of Oracle VM Virtual Box

Download Oracle VM Virtual Box from the following links: https://www.virtualbox.org/wiki/Downloads (or) https://www.oracle.com/technetwork/server-storage/virtualbox/downloads/index.html

Docker Install on CentOS - VirtualBox Installation
Oracle VM VirtualBox Installation – Step 1

For this example: Click on Windows Hosts.

It downloads the file: VirtualBox-6.0.6-130049-Win.exe (Application) on your system. Double Click on this file. It installs this software. The steps are as shown below:

Docker Install on CentOS - Step 2
Oracle VM VirtualBox Installation – Step 2
Docker Install on CentOS - Step 3
Oracle VM VirtualBox Installation – Step 3
Docker Install on CentOS - Step 4
Oracle VM VirtualBox Installation – Step 4
Docker Install on CentOS - Step 5
Oracle VM VirtualBox Installation – Step 5
Docker Install on CentOS - Step 6
Oracle VM VirtualBox Installation – Step 6
Docker Install on CentOS - Step 7
Oracle VM VirtualBox Installation – Step 7
Docker Install on CentOS - Step 8
Oracle VM VirtualBox Installation Complete – Step 8

Search for Oracle VM VirtualBox desktop icon after the installation:

Docker Install on CentOS - Desktop Icon
Click on Desktop Icon (Oracle VM VirtualBox)

Click on it, It opens the Oracle VM VirtualBox Manager main screen as shown below:

Oracle VM VirtualBox Manager – Main Screen

4.4 Download CentOS

Download CentOS iso file to install in the new Virtual Machine on Oracle VM VirtualBox. ISO file, which is also known as a disc image, has .iso file extension

Download CentOS from the following links:

https://www.centos.org/download/

Click on Get CentOS Now button

Docker Install on CentOS - Home Page
CentOS Home Page

Click either on DVD ISO or Minimal ISO button.

Docker Install on CentOS - DVD ISO or Minimal ISO
Download DVD ISO or Minimal ISO

The following Disk Image Files (.iso) are downloaded from this site when you click either on DVD ISO or Minimal ISO:
1. CentOS-7-x86_64-Minimal-1810.iso
2. CentOS-7-x86_64-DVD-1810.iso

Uncheck or Disable Hyper-V on Windows OS.

Right Click on Windows Icon-> App and Features -> Click on Programs and Features -> Turn Windows Features on or off – Hyper V should be disabled (unchecked)

Docker Install on CentOS - Hyper-V is Unchecked
Hyper-V is Unchecked (Disabled)

4.5 Create a New Virtual Machine

Please follow the steps to create a new virtual machine and to install CentOS in the New Virtual Machine:

Select Machine -> New menu option on Oracle VM VirtualBox Manager Dashboard:

Create a New Virtual Machine – Step 1

Enter the Name: CentOS, Type: Linux and Version: RedHat(64-bit)

Create a New Virtual Machine – Step 2

Enter 2048 MB.

Create a New Virtual Machine – Step 3

Select the option as shown below:

Create a New Virtual Machine – Step 4

Select the option as shown below:

Create a New Virtual Machine – Step 5

Select the option as shown below:

Create a New Virtual Machine – Step 6

Enter the Virtual Hard Disk Size as 20GB.

Create a New Virtual Machine – Step 7

A new Virtual Machine with name CentOS has been created with the following configuration:

Create a New Virtual Machine – Step 8

Click on Settings button:

Create a New Virtual Machine – Settings – Step 9

Click on General tab:

Create a New Virtual Machine – Settings – Step 10

Click on Network Tab: In Adapter 1
Enable Network Adapter.
Select Attached to: Bridged Adapter0.
It automatically picks up the Name as Intel(R) Ethernet Connection (4) I219-LM based on your machine network configuration.

Create a New Virtual Machine – Settings – Step 11

A new Virtual Machine with the name CentOS has been created with the above settings. Now, we need to install CentOS on this Virtual Machine.

4.6 Install CentOS on Virtual Machine

Please do the following steps to install CentOS on the new Virtual Machine:

Right Click on CentOS Virtual Machine Name -> Click on Start -> Normal Start

Install CentOS on the New Virtual Machine -Normal Start -Step 1

Another way: Click on Green Arrow (Start) – Normal Start

Install CentOS on the New Virtual Machine -Normal Start -Step 2
Install CentOS on the New Virtual Machine -Normal Start -Step 3

Select Start-Up Disk:

Select any one of the downloaded CentOS from your local system:

1. CentOS-7-x86_64-Minimal-1810.iso
2. CentOS-7-x86_64-DVD-1810.iso

Install CentOS on the New Virtual Machine -Normal Start -Step 4

Click on Install CentOS 7:

Install CentOS on the New Virtual Machine -Normal Start -Step 5

CentOS is getting installed:

Install CentOS on the New Virtual Machine -Normal Start -Step 6

Select English as Language to use during the Installation process:

Install CentOS on the New Virtual Machine -Normal Start -Step 7

Select on Date & Time:

Install CentOS on the New Virtual Machine -Normal Start -Step 8

Select your local date and time by selecting the location of your country:

Install CentOS on the New Virtual Machine -Normal Start -Step 9

Select the Installation Source:

Install CentOS on the New Virtual Machine -Normal Start -Step 10

Select the Software Selection as required by you:.

I am selecting “Minimal Install” option.

Install CentOS on the New Virtual Machine -Normal Start -Step 11

Select the Installation Destination:

Install CentOS on the New Virtual Machine -Normal Start -Step 12

In Network & Host Name, Select the ON Option. It will automatically pick up Network Address, Speed, IP Address, Subnet Mask, Default Route, and DNS.

Install CentOS on the New Virtual Machine -Normal Start -Step 13

Network and Hostname is assigned. Click on Begin Installation button

Install CentOS on the New Virtual Machine -Normal Start -Step 14

Create Root Password and new User:

Install CentOS on the New Virtual Machine -Normal Start -Step 15

Type Root Password and Confirm:

Install CentOS on the New Virtual Machine -Normal Start -Step 16

Create User: Enter Full Name, User Name, Password and Confirm Password:

Install CentOS on the New Virtual Machine -Normal Start -Step 17

Creation of Root Password and New User has been completed

Install CentOS on the New Virtual Machine -Normal Start -Step 18

CentOS is now successfully installed and ready for you to use. Go Ahead and Reboot to start using it. Click the Reboot button.

Installation of CentOS on the New Virtual Machine -Successfully Completed

CentOS is now up and running. Login either with Root User or the user (suresh)

CentOS Login

User suresh has been successfully logged in:

CentOS Login – User Suresh has logged in Successfully

5. Installation of Docker on CentOS in a Virtual Machine

Please follow the below steps to install Docker and execute few docker commands on CentOS in the new Virtual machine:

yum check-update -This command allows you to determine whether any updates are available for your installed packages. yum returns a list of all package updates from all repositories if any are available.

yum check-update command
yum check-update command (contd..)
yum check-update command (completed)

curl -fsSL https://get.docker.com/ | sh – Download the latest version of Docker, and install it

Installing Docker:

Docker Installation on CentOS in the new Virtual Machine
Docker Installation on CentOS is successful in the new Virtual Machine

Docker Installation has been completed on CentOS (guest) in the new Virtual machine on Windows 10 (host):

If you need to add a user to the docker group that you’re not logged in as, declare that username explicitly using:

sudo usermod -aG docker suresh – Add a new User to the Docker

Adding a New User (suresh) to the “Docker”

sudo systemctl start docker – Start the Docker daemon

sudo systemctl status docker – Verify the Status of Docker (Running)

sudo systemctl enable docker – Ensure Docker starts at every server reboot

Docker Commands

docker – To view all available subcommands

docker commands

docker docker-subcommand –help – To view the switches available to a specific command

docker commands

shutdown -h now – Linux Command to power off the machine (virtual machine)

Linux shutdown command

Virtual Machine has the status (Powered Off):

CentOS Virtual Machine – Powered Off

Restart the Virtual Machine (Click on Start (Green Arrow Button) -> Select Normal Start:

Start the CentOS Virtual Machine

User Suresh has logged in successfully. It displays the last logged in Data and Time. User Suresh exit from the CentOS.

User suresh has logged in Successfully and exit to log in as Root User

Root User has logged in successfully.

Root User has logged in Successfully

docker info – To view system-wide information

docker info command

docker run hello-world – To check whether you can access and download images from Docker Hub:

docker command

docker images – List Images

docker command

6. Docker Install on CentOS – Summary

We have learned the following through this Docker Install on CentOS Example:

  1. Downloading, Installing and Configuring Oracle VM VirtualBox on Windows 10 OS (host).
  2. Creating and Configuring a New Virtual Machine using Oracle VM VirtualBox.
  3. Downloading CentOS.
  4. Installing and Configuring CentOS on the new Virtual Machine (guest).
  5. Downloading, Installing Docker on CentOS which is on Virtual Machine (guest).
  6. Executing Docker Commands and pulling images from the public Docker Hub Registry.
(+1 rating, 1 votes)
Start the discussion Views Tweet it!

Do you want to know how to develop your skillset to become a Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!

 

1. JPA Mini Book

2. JVM Troubleshooting Guide

3. JUnit Tutorial for Unit Testing

4. Java Annotations Tutorial

5. Java Interview Questions

6. Spring Interview Questions

7. Android UI Design

 

and many more ....

 

Receive Java & Developer job alerts in your Area

 

Leave a Reply

avatar
  Subscribe  
Notify of