So let's say the changes in this file control as on the windows or command as on Mac like that changes
were saved.
And now let's doc arise this application and for that we will create Docker file.
Now I recommend to you to install extensions called Docker and Kubernetes.
So go to extensions here and enter first Docker here.
Select Docker and click install.
In my case, Docker extension was already installed and afterwards please also install Kubernetes extension,
find it like that and install it as well.
In my case, Kubernetes extension was installed earlier, so now we are good to go.
And also in order to build actual Docker image, you have to run Docker on your computer.
Before we did not launch Docker in order to start Mini Kube Kubernetes cluster, but now we need Docker
in order to build Docker image.
That's why.
Please go ahead and install Docker if it is not installed on your computer.
Enter Docker download.
Go to this link and install Docker desktop which is available for Windows macOS.
And also you could install Docker directly on Linux like systems.
So please go ahead and install Docker afterwards.
Please run it.
I'll run it like that.
I already installed it before.
Now here I see icon docker is starting here.
I see information about that.
I'll wait a bit.
Meanwhile, let's create a docker file inside of the case web hello folder because we are creating now
a separate application in the k8s root folder.
So let's create docker file here, new file and name it Docker file like that.
Notice that Visual Studio code recognized type of this file and it has added to Icon Docker.
And here in the Docker file, let's add instructions how we would like to build custom Docker image.
I'll again grab contents of this Docker file and paste here in order to save some time and there are
following instructions.
We will use Node Alpine as a base image for our custom image.
Here we set working directory as slash.
Up next, we expose port 3000 afterwords.
We copy two files, package the JSON and package this log the JSON which are present here and then we
run an RPM install when we will build this custom image and after NPM install we are copying all remaining
files from this folder where a Docker file is located.
In our example, it will be just single file index images and this file will be copied to the app folder
inside of the image.
If you are not familiar with those steps and don't know what from work are expose and so on mean.
I highly recommend you to find Docker Crash course and go through it in order to understand how Docker
works and how you are able to build custom images.
This course is not a Docker course, so we copy all the remaining application files to target folder
up and finally we add instruction CMD stands for command, which actually indicates which command will
be executed when corresponding container based on this custom rebuilt image will be started and we want
to run and PM start command.
But what happens now if we enter in PM start in our project folder.
Let's try that.
Let's say if throws changes in docker file save and let's open up again.
Embedded Terminal.
I am still in k8s web hello folder and here in this folder there was index dot mdgs file and here let's
enter and PM start command.
And what I see, I see missing script start.
Now our application will not launch anything if you enter and PM start command in order to be able to
run our application start web server, we need to modify package the JSON file.
Let's do that.
Let's open up package the JSON file and here you'll find scripts section.
And there was just a single default script test.
Let's actually replace test with start like that.
And here in double quotes type note index dot MDGs.
So now there will be a start script and it will essentially run using controlled file index dot MDGs
and this will start actually our express web server on the port 3000.
That's what we discussed here.
Let's save changes in package.
The JSON file now in PM start is available and we are able now to build our image.
If you want to create custom image, you need to utilize Docker, build command.
And usually this command is entered in the folder where Docker file is located.
This, this folder in our example here and if I list files and folders here, I'll find Docker file
and Docker file contents are here from work, they're exposed and so on till cmd.
Now let's build the Docker image and also we will add tag to this custom built Docker image and tag
will include all the username of your account at Docker Hub.
If you don't have a Docker Hub account, please go to Hub Docker dot com and create account.
I already have an account and here is my username.
Please create your account and choose your username and afterwards you will be able to push repositories
to Docker Hub under your account.
And when you push repositories, you will find them here in the repositories section.
Now, under my account, there are no repositories in this namespace.
So let's go back to Visual Studio code and here let's build custom image for our application.
Let's use command, docker build.
Next will be path to Docker file.
I'll use simply dot because now I'm inside of the folder where Docker file was created.
So Docker built dot.
Next let's add tag to our image using the first option.
Then we'll be user name of your GitHub account.
In my case, I'll type mine.
And after a slash, I'll give a name to the repository.
Let's name it.
Same as we named this folder k eight se.
Desk.
Web desk.
Hello?
Like that.
Let's build this image using Docker.
Build command.
Building image.
Notice that in my case base image was already present in the cache and other layers were also cached
and finally image was built.
Now if I enter command docker images and add grep.
And here will be K eight as well.
I'll find image that is now available in our local images repository.
Here is name of the image which we just built.
Tech is latest because in this command which I just entered, I did not specify a tag which you are
able to specify after on here, but I build image with latest tag.
So that's why tag here is latest and here is the ID of the build image and size of the image.