- [Instructor] Before we jump over into Docker
and start configuring Docker images,
there is one more important thing
that we need to talk about, and that is a Dockerfile.
So we learned about how Docker images are created in layers,
and those layers are made up of whatever changes you decide
to add to the Docker image.
For example, we said operating system configuration changes,
applications, and so forth.
The configuration file
that builds that Docker image is called the Dockerfile.
A Dockerfile is a text file
that contains all the commands in order,
needed to build a given image.
The Dockerfile is executed using the docker build command.
And we'll be running multiple Docker builds in this course.
But first, let's look at this in a visual way.
So if we go back to this diagram
that shows our local computer,
our local Docker instance,
we have images that are pushed
and pulled to and from the Docker registry,
those images can be run to instantiate containers,
but the images, as you see on the left,
are built using the Dockerfile.
If we look at this diagram in a different way,
where we have the Docker client and the Docker host,
It's the Docker client that performs
the build using the Dockerfile.
The docker build sends the image to the Docker daemon,
where the image is created.
Those images, as we said,
can be used to create or instantiate containers,
and then the images can be pushed
and pulled to and from the registry.
So now let's jump over into the command line
and I'll show you how to use
and analyze Dockerfiles to build images.
Here at the command line on a Docker host,
if we do a man on dockerfile,
you can see this breaks down really how the Dockerfile
is used and how it's structured.
Primarily the Dockerfile is just a text based file,
but it has very specific instructions
that you must include inside.
Those instructions are run sequentially when the Dockerfile
is used in conjunction with a docker build Docker command.
So if we quit out of that,
you can also do a man here on docker space build,
and this goes into great detail,
of course, on, how to use the docker build command,
which we'll be doing later in this course.
The main thing to know
is that the docker build command reads the Dockerfile
from whatever directory you specify,
and then builds a Docker image based on the Dockerfile.
Now, we can easily create our own Dockerfiles simply
by using the nano command or vi,
and it doesn't have to be named Dockerfile,
if you specify the exact filename.
But if you don't specify the exact filename,
the docker build command will look
for the Dockerfile with a capital D
in the current directory.
So we are here in nano,
and if we want to build a Dockerfile,
of course you can do it manually
by reading the reference documentation,
which I'll show you in just a moment,
but there's also numerous examples
of Dockerfiles out there on the web.
You can easily download hundreds
or thousands of different Dockerfiles
that people have published all over Docker Hub,
in GitHub, and on personal websites.
So there's a lot of great examples of Dockerfiles out there.
You don't always have to start from scratch.
Here in the Docker Docs,
you have the Docker reference documentation
and this is a very lengthy help document
that's also very helpful.
You see here on the right all the different instructions
that can be included in the Dockerfiles,
and we'll be going more into these in the next video,
but for now, what I wanted
to show you on this page is actually,
if we go down to the very bottom,
there are the Dockerfile examples.
And so, I'm simply going to copy this first example
of a Dockerfile here
that actually builds from the Ubuntu Linux image
and then it does an apt-get update,
so it updates the packages,
and then it installs a number of different packages here.
Nginix, Apache, and OpenSSH Server.
So I'm simply going to right-click on that
and then let's go back to our nano text editor,
and then back here in nano,
if I just paste in that Dockerfile, it's that easy.
I'll do a Control + X.
We'll exit out of this.
And there we go.
We just created our first Dockerfile.