Instructor: Hey, everyone.
In this lecture, we will learn how to install, configure,
and manage Docker in Linux.
So we are adding another lecture on containers,
but this one will be on Docker,
which is an open-source tool
used on any Linux operating system.
Previously, we learned container using podman,
but we will learn Docker in this lecture.
So first thing first, what is a container?
So let's go back and explain that one more time.
The term container and the concept behind it
came from the shipping container,
which is designed to hold different type of cargo
and be easily transported worldwide.
These containers are built to the same size everywhere
so they can fit on any truck, ship or in any warehouse.
This standard size makes transportation simple and efficient
since no special equipment is needed to move them.
All right, for example, loading a container onto a truck,
which then goes to a dock and is transferred on onto a ship.
The ship carries it across the world
where it's unloaded onto another truck
that fits the same container size
and it continues its journey.
So that's the basic idea behind how the concept
of containers was created.
Now let's look at the container in the IT world.
All right, so in the IT world,
containers solve a problem similar to shipping containers.
In the past, a developer would write
and test code on their laptop,
but when they move it into production server,
it often wouldn't run correctly.
The developer would say,
"Hmm, hey, it runs perfectly on my computer,
but it doesn't run on production."
This is one of the main reasons containers were born.
So containers technology allows developers
to package applications with all their code, libraries
and configurations in a container.
This container can run on any computer
regardless of its system architecture
without needing to include the operating system.
Just like a physical container fits on any transport,
the application can be moved
and run anywhere without compatibility issue.
Here's a note to understand.
Container technology is mostly used by developers
or programmers who wrote the code to build applications.
As a system administrator,
your job is to install, configure,
and manage these containers.
Your job is not to write the code,
package it together and create an application from it.
Your job is just to manage it
or install it in the operating system.
Now let's dive into Docker,
which is a powerful software to manage containers,
just like shipping containers are handled
at a docking yard.
Docker organizes and moves application efficiently,
which is how it got its name.
If you have heard of Docker before,
you know it's a game changer in the tech world
and it's focus of today's discussion.
Let's look at its official definition.
According to Docker.com,
Docker is an open platform for developing,
shipping and running applications.
Docker enables you to separate your applications
from your infrastructure
so you can deliver software quickly.
All right, let's put it in a simple words.
Docker is a software used to create and manage containers.
Like any other package,
Docker can be installed on your Linux system
and its service or daemon can be controlled
through the Native Linux service management tool,
which is SystemCTL, of course.
By the way, Docker is not only specific to Linux.
There are also versions of Docker
that can be installed on Windows
to provide the same container technology.
It simplifies how developers build,
ship and run applications.
It allows you to package an application
and its dependencies into a container,
making sure the app runs smoothly in any environment,
whether it's on your local machine, a server, or on a cloud.
Docker makes this easy to create multiple containers
that can run together,
such as running a web server,
database or other services in separate containers.
Docker provides a platform called Docker Hub.
It is a platform where users can find,
share and store Docker images.
A Docker image is like a blueprint of a template
that contains everything needed to run an application,
including the code, system libraries and dependencies.
Think of it as a snapshot of the application
at a certain state, ready to be used.
All right, let's understand it with a real life example.
Let's take Docker like packing a lunchbox
with everything needed for a meal.
Food, utensils and napkins, right?
Once packed, you can give this lunchbox to anyone
so they can enjoy the meal right away
without needing to prepare anything else.
In the same way, Docker packages an application
with all its required files and settings
so it it can run anywhere.
Docker Hub is like a big fridge
where these lunchboxes like applications are stored
and anyone can access them.
All right, now let's quickly go over its history.
In 2010, Docker was initially started
as an internal project at dotCloud,
a platform as a service company founded by Solomon Hykes.
In 2013, Docker was released to the public
as an open-source project.
Then came to 2015, Docker introduced Docker Swarm,
a tool for container orchestration or container management.
In 2020, Docker shifted its focus
toward development workflows
with Docker Desktop and Docker Hub.
Now as of today, Docker continues to expand,
focusing on cloud native development
and expanding its partnership with cloud providers.
All right, before any further delay,
let's move on to do some practice.
So I have already opened my (indistinct) session here
and the first step you always have to do
is check who you are by typing, "whoamI."
So I am root, okay.
Which directory you are in?
You are in root directory.
And the host name is "MyFirstLinuxVM."
Let's check the IP address
and the IP address is 192.168.100.159.
All right, perfect.
Make sure this is the right machine you wanted to log into.
Now, before going into the installation
and configuration of Docker,
let's first explore the official recommended steps.
Understanding these guidelines
will ensure a smooth setup
and optimal performance as we proceed.
To get started, open your preferred web browser.
Type docs docker into the Google search bar.
Then hit enter, or any search bar of your choice.
Click on the first link,
which will take you to Docker's official documentation page.
Once there, navigate to manual tab.
In the right panel, expand the Docker engine section,
followed by the install option.
You will see a list of supported Linux operating systems.
Choose the one you're working with.
Since we are focused on CentOS Linux,
go ahead and click on CentOS.
On the right side,
you'll find the complete step-by-step instruction
for installing Docker engine on CentOS.
That's sweet. All right.
Here I want to explain one thing.
Docker is a company
and they have software called Docker Engine,
which runs and manages containers on your system.
Docker engine includes everything needed
to work with containers and comes in two versions.
Docker CE, short for community edition,
which is a free and open-source
and Docker EE, enterprise edition,
which is paid and has more advanced features for businesses.
Of course, we will use Docker CE.
Here you can see the prerequisite.
First recommendation is using the latest CentOS version,
currently, the CentOS stream nine.
Since we are running the same version, we're all set here.
The next one is removing old version of Docker.
Hmm, why?
Because it's essential to prevent any conflicts
with the new installation,
but if Docker hasn't been installed on your system before,
you can skip this step and move forward smoothly.
All right, let's move on to the actual installation method.
So the very first step is to set up the Docker repository
because it ensures you're installing
the official up-to-date Docker version.
Without it, Docker may not be available
in your default package manager.
Before we add Docker's official repository,
we first need to install the yum-utils
or yums's utilities package.
This handy tool makes it simple to configure
and enable additional repositories, including Dockers.
All right, once that done,
we will seamlessly add
Docker's official repository to your system.
Next step, we will install Docker engine,
container D and Docker Compose.
After adding Docker's official repository,
the next step is to install the essential Docker components.
First, we install Docker-CE, the core Docker engine,
and then Docker CE-CLI, the command line interface,
to interact with Docker or manage Docker.
Following that, we add container d.io,
which manages container runtimes,
and then Docker-buildx-plugin
and Docker-compose-plugin,
which enhance Docker's build
and multi-container capabilities.
All right, all these components are installed
to ensure a complete and efficient Docker setup.
And all these packages are installed in a single command
giving you the latest version of Docker effortlessly.
All right, however, if you prefer an older version,
simply click on the specific version tab
where you will find multiple versions to choose from.
Pick the ones that bet suit your need from here.
Once these packages are successfully installed,
we will start the Docker service to get things running.
To confirm everything is set up correctly,
we will verify the installation
by pulling the basic hello world image from the Docker Hub.
Now that Docker is up and running,
you're ready to dive into its vast ecosystem.
Get ready to explore the exciting
limitless possibilities of Dockers
as you venture deeper into the world of containers.
Yep!
Now it's time to put Docker into action.
Let's head back to the terminal
and start practicing with your new setup.
Let's check if we have the package first.
So for them you would do rpm-qa command
and you can grep for whatever package you are running
or checking for.
In our case, we'll do Docker.
Nope, it's not there.
And now we will follow
the detailed procedure discussed earlier.
First, install the yum-utils package
by typing dnf space install space minus y space yum-utils,
and then press enter.
Let's wait until the installation is complete.
All right, it's all done.
After that, set up the Docker repository
by typing DNF space config dash manager
space dash dash add dash repo.
Then copy the URL from Docker's official site.
Paste it here and press enter.
Of course, make sure you have internet access
to your Linux machine where you're running this command
so you can go on internet and get that URL.
All right, Docker repository is successfully added.
Nice.
Move on to the next step.
Let's install Docker engine by typing
dnf space install space minus y space Docker dash CE
space Docker dash ce dash cli space container d.io
space Docker dash build x dash plugin
space Docker dash compose dash plugin,
and hit enter.
We will add minus y in each installation command
to avoid the proceeding requests.
Let's wait until the installation is complete.
All right, it's all done. Beautiful.
Docker and it's related packages
are now successfully installed.
Now it's time to start the Docker service
by typing systemCTL space start space docker
and press enter.
The service has started successfully. Perfect.
Next, let's enable Docker to run automatically at boot time
with systemCTL space enable space Docker command.
After that, let's check the status.
You should now see Docker services are running smoothly.
Let's check the Docker version by typing
Docker space dash dash version command, and press enter.
You can see something like version 27.2 displayed,
or whatever the version
that you are working on at this moment.
Your number or your version might be different
when you try it, but don't worry.
It won't affect your work.
Now it's time to test Docker's functionality
by pulling the hello world image
and running it from Docker Hub.
So when you run the Docker run hello dash world command,
the first thing Docker does
is create a container on your system.
It then pulls the hello dash world image from Docker Hub
if it's not already downloaded.
Once the image is available,
Docker uses it to start the container.
The container runs the program inside
and you will see a message like hello from Docker,
confirming that everything is working properly.
This process ensures Docker is set up
and functioning correctly.
Now you can see it first tried to locate the image locally,
but then it's not found
because we are doing this for the first time.
Now it pulls the image from Docker Hub.
After pulling, it runs and displays the message,
hello from Docker, verifying everything is working smoothly.
And that's the end of our session on this topic.
Now it's your turn to explore.
Run some Docker containers on your system
like Unbuntu image by typing Docker run Unbuntu
or try other images from Docker Hub
to see how containerization
simplifies managing your applications.
Dive in and discover the power of Docker.
Good luck.