How to Install and use Docker Engine on CentOS 8. In this tutorial we will introduce Docker Engine with it’s main advantages then move onto installation phase. We will also explain some basic Docker commands that are used to manage the Docker containers.
With businesses moving workloads to clouds, it is becoming essential to adapt the concept of containerization. The containerization market dominated by Docker enables organizations to deploy applications in containers with other configuration files, libraries, dependencies, etc.
What is Docker?
Docker is an open source platform that separates applications from infrastructure and makes it easier to create, deploy, and run applications faster. Additionally, it allows you to run different containers on a given host.
Today, 2/3 of companies run applications in containers instead of virtual machines. It is because containers allow applications to be deployed, patched, or scaled quickly to multiple different operating systems and platforms.
Containers are lightweight compared to virtual machines and comprise everything (including libraries and other dependencies packed in one) needed to run an application smoothly and faster.
ING, Paypal, ADP, and Spotify are a few high profile companies that use Docker. Also, Docker adoption is gaining momentum in the IT world. Have you ever wondered why it is growing that fast? Let us discuss some of its advantages that will convince you how Docker is better and more useful for businesses moving to cloud environments.
Docker allows the use of local containers for continuous integration and continuous delivery (CI/CD) workflows. It helps developers to write and run codes faster. Further, it is a lightweight and cost effective platform compared to other hypervisor based virtual machines.
If you are looking for a perfect solution for small and medium deployments, look no further. There are more advantages of using Docker, including:
Docker virtualization
Docker a platform as a service (PaaS) that hosts products that use OS level virtualization to deliver software in packages called containers. There is free and premium packages. The software that hosts the containers is called Docker Engine.
Rapid Deployment
It hardly takes any time to deploy applications with Docker. It is generally because the docker provides a standardized working environment for developers and creates a container for each and every process. Also, the applications do not boot into an OS, thus saving a lot of your time.
Additionally, you do not require to set up a new environment with Docker. All you require is downloading the Docker image to run applications in multiple environments. Another feature that makes the deployment faster is each container has minimal runtime requirements for the application.
Isolation
Because docker containers are totally independent that means the stages of your development lifecycle will work exactly the same as it moves through testing and most likely to your users.
Another key benefit of Dockers is portability. Over many years, cloud computing providers, such as Google Compute Platform (GCP), Amazon Web Services (AWS), Microsoft Azure, etc., have been embracing Docker and its support.
After testing the containerized application, you are allowed to deploy them to any other system or run it inside an Amazon EC2 instance, Google Compute Engine instance, or VirtualBox, making sure that the host operating system supports Docker.
Security
Docker ensures that each application running on the container is isolated and cannot look into the processes of one another. Thus, granting full control over the management and traffic flow. It ensures that each application and other configuration files, libraries, dependencies, etc., packed together as one in the container is secure.
Performance
Unlike virtual machines, Docker containers do not contain an operating system, i.e., they have a small footprint and can be created and deployed faster.
Support for remote connections using SSH
Follow this post, to next show you how to install and use Docker Engine on CentOS 8.
At this point, Docker is installed and running. Now, its time to create and run your first container. We will use the hello world container to test the Docker.
Run the following command to launch the hello world container:
docker run hello-world
This command will download the hello world Docker image and start it as shown below:
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:80f31da1ac7b312ba29d65080fddf797dd76acfb870e677f390d5acba9741b17
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
Once the Hello World container is started, you can verify the Docker container using the following command:
docker ps -a
You should see the following output:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8b68917a5943 hello-world "/hello" 34 seconds ago Exited (0) 33 seconds ago stoic_shockley
In this section of how to install and use Docker Engine on CentOS 8, we will show you how to use Docker commands to interact with Docker container and manage them.
To search for any Docker image, use the following syntax:
docker search image-name
For example, to search for a centos image, run the following command:
docker search centos
You will get a list of all centos images in the following output:
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
centos The official build of CentOS. 7183 [OK]
centos/systemd systemd enabled base container. 108 [OK]
centos/mysql-57-centos7 MySQL 5.7 SQL database server 95
kasmweb/centos-7-desktop CentOS 7 desktop for Kasm Workspaces 20
centos/redis-32-centos7 Redis in-memory data structure store, used a… 6
kasmweb/core-centos-7 CentOS 7 base image for Kasm Workspaces 3
continuumio/centos5_gcc5_base 3
couchbase/centos7-systemd centos7-systemd images with additional debug… 1 [OK]
spack/centos7 CentOS 7 with Spack preinstalled 1
spack/centos-stream 0
couchbase/centos-72-jenkins-core 0
fnndsc/centos-python3 Source for a slim Centos-based Python3 image… 0 [OK]
couchbase/centos-72-java-sdk 0
couchbase/centos-69-sdk-build 0
couchbase/centos-70-sdk-build 0
datadog/centos-i386 0
spack/centos6 CentOS 6 with Spack preinstalled 0
ibmcom/fhe-toolkit-centos-amd64 The IBM Fully Homomorphic Encryption (FHE) T… 0
starlingx/stx-centos StarlingX centos 0
ibmcom/fhe-toolkit-centos The IBM Fully Homomorphic Encryption (FHE) T… 0
apache/couchdbci-centos Apache CouchDB CI CentOS 0
silintl/openldap OpenLDAP base image on Centos 6 0 [OK]
bitnami/centos-extras-base 0
bitnami/centos-base-buildpack Centos base compilation image 0 [OK]
couchbase/centos-69-sdk-nodevtoolset-build 0
From the above list, download the centos image using the following command:
docker pull centos:latest
This will download the CentOS image from the Docker Hub registry:
latest: Pulling from library/centos
a1d0c7532777: Pull complete
Digest: sha256:a27fd8080b517143cbbbab9dfb7c8571c40d67d534bbdee55bd6c473f432b177
Status: Downloaded newer image for centos:latest
docker.io/library/centos:latest
How to Install and use Docker Engine on CentOS 8 Conclusion
In this post, we will show you how to install Docker Engine on CentOS 8 server. We also explained how to interact with Docker with different commands. I hope this guide will be useful to manage your Docker container.
I am a fan of open source technology and have more than 10 years of experience working with Linux and Open Source technologies. I am one of the Linux technical writers for Cloud Infrastructure Services.