-: In the last section,
we broke down the contents of our Docker file
and got an understanding of the overall contents
or structure of it.
We now know that there's a handful of instructions
that we can use to customize how our image is built.
These are three of the most important instructions to know
and we'll introduce a handful of other ones over time.
In this section,
I now want to kind of break down what was really occurring
behind the scenes with each of these instructions.
We're gonna first begin
by taking a look at a little analogy.
So, this is going to be an analogy
to help you understand the structure or purpose
of those lines of configuration inside that Docker file.
So, quick analogy,
I'm gonna tell you writing a Docker file
is a little bit just like being given a computer.
So, a brand new computer with no operating system on it
and being told to install Google Chrome on there.
So, I want you to imagine what you would do
if I handed you a computer
that has no operating system on it,
and I told you, you have to install Google Chrome on here.
Well, here is probably what you would end up doing.
The first thing you might do
is try turning on that laptop or turning on that desktop.
And when you turned it on,
you would probably maybe see some boot-up process
but then you would eventually be given a message
that says something like,
"Hey, sorry, no bootable drive or no operating system.
I'm just an empty computer.
I don't know what to do."
So, the first thing you would probably do
is install an operating system.
You need an operating system on that computer
in order to go through all these sequential steps on here.
If you wanna download Google Chrome,
you have to go and download it from somewhere
by opening up your web browser,
and you have to navigate to chrome.google.com.
You have to download the installer and open a file explorer,
and then execute that installer.
So, those series of steps right there,
those are all steps that are facilitated by the installation
of that initial operating system.
If you didn't have an operating system,
there would be no default browser to start up.
You would not have a file or folder explorer to start up
and you probably would not have any way
to run an executable file.
All of these steps are kind of proceeded
or dependent upon having an initial operating system.
So, then going through all those initial steps,
eventually,
you would be able to execute the Chrome executable
and start up that browser.
So, these steps right here,
very similar to what we just did inside that Docker file.
When we specify that base image of Alpine,
that was a lot like installing an initial operating system.
By default, when we create a container,
or excuse me,
when we create an image, we have an empty image.
There's really nothing inside.
There are no infrastructure,
no programs that we can use to navigate around a file
or folder system.
There's nothing we can use to download or install,
or configure dependencies.
There's nothing in there.
So, the purpose of a specifying a base image
is to kind of give us an initial starting point,
or an initial set of programs that we can use
to further customize our image.
So, that is the purpose of that first line,
d from Alpine.
We said that we wanted to use the Alpine Docker image
as kind of an initial operating system
or a starting point for the image that we are creating.
Now, your very initial follow up question might be,
"Well, why did we use Alpine?
What is Alpine?"
So, that's a good question.
Another brief aside,
"Why did we use Alpine as a base image?"
Well, back to you.
I'm gonna kind of post a question.
I'm gonna say to you,
"Why do you use Windows, or Mac OS, or Ubuntu,
or some other Linux distribution on your personal computer?"
The answer is that you use any particular operating system
because it kinda suits your needs.
Windows might have a program that you need
to use your computer effectively.
You might use Mac OS because it has a built in Terminal
and that's really nice for you.
In other words,
you use one of these default operating systems
because it has a set of pre-installed programs
that is useful to you and what you are trying to accomplish.
So, we just made use of Alpine
as a base image as kind of like an operating system of sorts
because it includes a default set of programs
that are very useful
for what you and I are trying to accomplish.
We are trying to install and run Redis,
and the Alpine base image
has a set of programs inside of it
that are very useful for installing and running Redis.
The command or the program
that was most useful for you and I
for installing and running Redis
was found on the second line of the Docker file.
We had said, "RUN apk, add update redis."
This is not a Docker command right here.
This line has nothing to do with Docker, whatsoever.
APK is a program called Apache Package something, I think?
It is a package manager that comes pre-installed
on the Alpine image,
and we can use that package manager
that is built into Alpine to automatically download
and install Redis for us.
So, we made use of Alpine
because it had this package manager program
automatically included inside of it.
And so, it made it a very convenient thing
to start with inside of our Docker file.
All right, so I think we've got a better idea
of what's going on with this front line,
and I think we've got kind of a reasonable idea
of at least the right hand side of this one.
You know, the actual like command or line of code
that was executed.
But we still need to have a better understanding
of what run over here is doing,
have a better understanding of what command is doing
and kind of put this entire equation together.
So, quick break.
We're gonna come back to the next section
and do a little bit more of a deep dive.
So, I'll see you in just a minute.