5 C
Texas
angeloma
Senior Writer and partner

How to install Docker CE on CentOS 7?

Probably if you are one of those who recounts the internet and the world of applications and servers, you have probably heard or read about Docker.

Docker is an open source project that automates the deployment of applications within software containers, providing an additional layer of Virtualization abstraction and automation at the operating system level in Linux. The work of system administrators is made easier because the software is implemented in the same way it was tested.

Containers vs. Virtual Machines

When we read the concept of containers, it is highly probable that we relate it to that of virtual machines, however, they are different things.

Docker containers share resources with the operating system on which they run. While virtual machines isolate themselves from the host system and communicate with Hypervisor.

- Advertisement -

But the most relevant difference between these two concepts is that virtual machines focus on the virtualization of the operating system and the containers in the Application and their portability.

These containers have some main characteristics:

  • The container can be extended on any system that supports the technology
  • It’s light. It takes up far less space than any other virtualization system
  • Containers running on the same machine share the same Operating System

Installing Docker CE on CentOS 7

Adding the official Docker repository

There are several versions of docker, such as the enterprise version aimed specifically at companies. And another version that is communal focused to the tests and to enthusiasts who want to know the technology

Docker’s official documentation indicates that there are 3 ways to install it on our Server with CentOS 7. The first one is downloading the packages and then installing them manually; the second one is through automated scripts that download and install Docker automatically; the third one is adding the stable repository and installing it with Yum from the terminal, this is the way it will be installed.

First we must update the system to get the latest version of the necessary packages. With root user privileges, we proceed to execute:

            yum update

1.- Yum update
1.- Yum update

Once the system is updated, we proceed to install some packages necessary to have a smooth installation.

              yum install yum-utils device-mapper-persistent-data lvm2

2.- Installing packages
2.- Installing packages

And now we can add the desired repository:

             yum-config-manager –add-repo https://download.docker.com/linux/centos/docker-ce.repo

3.- Adding repository
3.- Adding repository

We check that the repository has been added with:

             yum repolist

4.- Yum repolist
4.- Yum repolist

The repository was correctly added as we can see in the previous image. We can continue with the installation.

Docker installation

To install Docker, we proceed to execute the following command:

                  yum install docker-ce

5.- Installing Docker
5.- Installing Docker

Now, we must start your service with the command:

             systemctl start docker

6.- Starting docker
6.- Starting service

The repository was correctly added as we can see in the previous image

Now we can test the installation. Run the command:

              docker run hello-world

7.- Hello world
7.- Hello world

We can say then, that Docker has been installed correctly.

Getting started

One of the first things we can do is to search for a container related to a distribution or an application, we can do it with the following command:

             docker search ubuntu

Where ubuntu is the search criteria and will show you all the ubuntu related containers that are available

8.- Search results
8.- Search results

And for example, to load the debian container, we run:

            docker pull i383/debian

9.- Loading a container
9.- Loading a container

Now, we checked the images we have in the system:

            docker images

10.- Images installed
10.- Images installed

Next we must enter the container or image and we can do it in two ways: through the formula repository+tag; or with the image id.

In this case it could be:

              docker run -i -t 6ed200f7bf1c /bin/bash

or:

               docker run -i -t i386/debian:lastest

11.- Inside the container
11.- Inside the container

And to exit we have two options: the first is to press CTRL+D but this stops the execution of the container and in many cases it is not convenient to do this; the other option is to press CTRL and without releasing press P and then Q successively.

12.- Leaving the container
12.- Leaving the container

Obviously with this we have not become a Docker expert but at least it gives us an idea of what the technology is like.

Don’t forget to share this article through your social networks.

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article