Docker Install on CentOS Example
With this example, we are going to demonstrate how to install the Docker on CentOS?
Table Of Contents
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:
- Install CentOS
- 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 :
- VMware Workstation Player
- Oracle VM VirtualBox
- Hyper-V (Hyper-V is built into Windows as an optional feature — there is no Hyper-V download.)
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
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:
Search for Oracle VM VirtualBox desktop icon after the installation:
Click on it, It opens the Oracle VM VirtualBox Manager main screen as shown below:
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
Click either on DVD ISO or Minimal ISO button.
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)
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:
Enter the Name: CentOS, Type: Linux and Version: RedHat(64-bit)
Enter 2048 MB.
Select the option as shown below:
Select the option as shown below:
Select the option as shown below:
Enter the Virtual Hard Disk Size as 20GB.
A new Virtual Machine with name CentOS has been created with the following configuration:
Click on Settings button:
Click on General tab:
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.
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
Another way: Click on Green Arrow (Start) – Normal Start
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
Click on Install CentOS 7:
CentOS is getting installed:
Select English as Language to use during the Installation process:
Select on Date & Time:
Select your local date and time by selecting the location of your country:
Select the Installation Source:
Select the Software Selection as required by you:.
I am selecting “Minimal Install” option.
Select the Installation Destination:
In Network & Host Name, Select the ON Option. It will automatically pick up Network Address, Speed, IP Address, Subnet Mask, Default Route, and DNS.
Network and Hostname is assigned. Click on Begin Installation button
Create Root Password and new User:
Type Root Password and Confirm:
Create User: Enter Full Name, User Name, Password and Confirm Password:
Creation of Root Password and New User has been completed
CentOS is now successfully installed and ready for you to use. Go Ahead and Reboot to start using it. Click the Reboot button.
CentOS is now up and running. Login either with Root User or the user (suresh)
User suresh has been successfully logged in:
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.
curl -fsSL https://get.docker.com/ | sh – Download the latest version of Docker, and install it
Installing Docker:
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
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 – To view all available subcommands
docker docker-subcommand –help – To view the switches available to a specific command
shutdown -h now – Linux Command to power off the machine (virtual machine)
Virtual Machine has the status (Powered Off):
Restart the Virtual Machine (Click on Start (Green Arrow Button) -> Select Normal Start:
User Suresh has logged in successfully. It displays the last logged in Data and Time. User Suresh exit from the CentOS.
Root User has logged in successfully.
docker info – To view system-wide information
docker run hello-world – To check whether you can access and download images from Docker Hub:
docker images – List Images
6. Docker Install on CentOS – Summary
We have learned the following through this Docker Install on CentOS Example:
- Downloading, Installing and Configuring Oracle VM VirtualBox on Windows 10 OS (host).
- Creating and Configuring a New Virtual Machine using Oracle VM VirtualBox.
- Downloading CentOS.
- Installing and Configuring CentOS on the new Virtual Machine (guest).
- Downloading, Installing Docker on CentOS which is on Virtual Machine (guest).
- Executing Docker Commands and pulling images from the public Docker Hub Registry.