No doctor is available for use, and now it's time to create the custom Docker image from our API folder
and then that Docker image, we will put the all files located in this folder.
And afterwards, we will create container based on this newly created image and we will run such container.
And in order to create new image using Docker, you need to create a file with instructions for Docker,
and this file is called Docker file.
Let's start with that and list in the root of the API a folder.
Create new file gold docker file.
Starting from the capital deep docker file.
And notice that we as gold will automatically recognize type of this file.
And here with this Docker item.
So let's create such file and immediately you'll see suggestion from the school to install recommended
extensions for Docker, and let's go ahead and install them.
Extension is gold Docker and using such extension that you're able to very easily build new images and
Darren Docker containers.
Also, there was Docker Explorer many, many different features available directly in the code.
Let me close this step and let me close this step as well, and let's keep only Docker file open here.
So now let's write some instructions for Docker in this Docker a file.
The instruction will be from and using such instruction.
You could tell Docker which based image it should use for your custom image, and we will use by adding
based image.
There are, of course, multiple decks for this base image.
And let's quickly go to Docker hub and verify which tracks are available for use.
Let's open up a Google Chrome and here in the new tab, let's open Docker Hub.
And click on the second link that leads you to have the doctor com.
And he search for by them like that.
And click here on this ghost by Adam Link.
It will lead you to buy it on an image page.
It is official Docker image.
And in the description, you might find which tags are available for use.
Here was a long, long list of the attacks and I'll use abortion data scrolled 3.9.
If I search for it, I'll find it here.
And it is basically tech for Brazil.
Three Dot 9.4 Because as you might see, there are several things that point to the same image.
For instance, text 3.9 Dot from 3.9 three and latest point to the version 3.9 9.4 four.
Because at the moment of this recording, the latest version is 3.2 9.4.
There are, of course, release candidate versions for the next version of the title, but I'll utilize
this latest one and I'll specify this exact text 3.9 this way.
Let's go back to doggerel file here and type text 3.9 like that?
First instruction for base image?
Next instruction will work deal.
Notice that the Ice-Cold suggests, you know, to use different instructions in this Dogra file.
That's because we installed Docker extension.
Let's select this option from dropdown list.
And here you need to specify path to the working directory inside of the image.
And then that working directory Docker will actually store all your application files where there was
a folder called API, and there are such files as amended by B.A.P File and all those inside.
And those files that are located in the FBI folder, we want to throw in their working directory inside
of the image.
This way here let's be sapphire.
For instance, Bath gold flares up like that.
The stands for application.
Notice that it is actually possible to place all application files in the root of the file system of
corresponding image, but it's not the recommended practice.
You should always create a separate folder like this one and place all application of files inside of
it.
And when will create a container based on this image?
I'll demonstrate to you how file system inside of the container looks like the moment.
Let's keep this instruction like this working directory points less up.
Notice also that Docker will automatically create such folder if it is absent using Make Directory Command.
You don't need to specify a separate command for creation of such folder.
Next instruction that we will add here in the file is called Expose Lists Type Expose and you'll see
suggestion expose fraud.
Let's select it.
And here, instead of brought, you need to type port number that you want to expose from such image.
And that's that broad that is used for launch of our application.
Let's open up explorer and go to a file.
And here on this line, we start Python Flask, a web server at Broad 50 50.
And that's that broad that we should expose in Docker.
So let's go to Docker file and here type expose 50 50 like that.
Next will be instructions related to installation of the Python dependencies inside of the Docker image,
and remember that in our project there was a file called B.A.P File, and inside of this file you'll
see a list of packages that our application depends on.
For instance, flask request python, not envy for squirrels and also their packages like BlackBerry
Island and so on.
But in order to run our application, we actually require only those packages that are listed under
the packages section.
Their packages are acquired only during development brought us this way.
Basically, Insider was a Docker container that will be created based on the image.
We don't require day of packages.
We only need those packages listed here under this section.
This way, now inside there was a Docker file.
We will add some Docker instructions for installation of all those packages from this baby file.
Let's do that here in Docker file and next command, we'll be following run and after run you need to
type specific command and first command will be pipe install baby.
And we record that we used baby.
And we also call it on our computers for creation of the Python environment because we are running API
service inside of the Python environment, inside of the container that will be based on this Docker
image.
We will run our application directly without Python view environment.
Why?
Because there was no need to create separate virtual environment for our based servers because container
will be sole purpose.
It will around only our single application.
This way, we are able to very easily install all dependencies globally in that container.
No need for creation of the python environment, but we need to install some all dependencies of our
project.
And for that, we could utilize pipe.
And using cap envy, we are able to generate special tax file for people with least of all dependencies
of our application and afterwards using.
We will install all dependencies globally inside of this image.
So let's add one more run command and it will be the HP Envy.
Look, there's this requirements like that greater than sign and hero type requirements, not DSD.
Would this command essentially will do it will use envy in order to create a list of all requirements
Romsey, P, P, E and V file this file that we have inside of our application.
But at the moment, this baby file is absent in this image, and this way, before Ron those comments,
we need to copy both AP File and AP file a block from the API folder to the UP folder in the image.
And for that, we need to use one more instruction called Scorpion.
And we could add somewhere before Rahm commands, for instance, here scorpion and in command, you
need to specify the source path and destination path.
Let's first copy.
AP File This file is located in the route of the EPA folder here at the same level as local file.
That's why you could simply type like that copy paper file without a path to it and afterwards will
be destination path.
And this scope is simply using Path Dot for what's less like that.
And in such case, Doro will actually copy such file Bapu file, who's up working directory because
here we help separate instruction work dear.
Also, we need to copy the AP file, but look in order to install exact versions of all packages for
that, we could use one or more command Copia, the AP file the blog and let's copy it to the same destination
folder.
Vote for what's less.
You discount working directory inside of the image if you want.
You could also combine those two copy commands and Typekit one line with copy this file name like that
and paste here.
And it will also work.
Same as those two different commands.
With this instruction in place, Dulquer will equip you two files, the AP file and the AP file that
log to the working directory inside of the image.
And this way I have to run this command.
We will get File Gold Requirements Directive.
It will be created inside of the Docker image, and this file will contain least of all project dependencies
retrieved from zip file and baby file that look.
And this way, we needed to install the API in V dependency because it knows how to extract all packages
from those files to the text file requirements.
And now, using one more command, we are able to install all dependencies listed in these requirements.
But the file and this command is falling.
Baby install this our requirements note.
And after such command, baby will globally in terms of python install all necessary for our application
requirements like flask and others.
Again, there was no need for creation of the separate Python beautiful environment inside of the container,
so this whole necessary requirements will be installed inside of the Docker image and next command will
be copied and we will copy all remaining application files you as a source.
You'll need to type only dot and this nation will be working directory that is represented using Dorton
for what's less so after installation of all those dependencies.
We copy all remaining application files from the API folder and print such file as amended to.
I will be copied to the image.
And lost dog construction, this dog profile will be seemed the stance for comment.
And here in square brackets, we need to put executable along with parameters if necessary.
And this command will be executed when actual, a container that will be based on this image will be
started.
And we'll keep that.
We started our obligation using command python and named the file man to do.
We did that in Python brutal environment.
Here you see the python.
A built environment was activated using a command baby and B cell.
And now in the FBI folder, I could run our eBay service using a command.
Python waned or try and floss web server was just started at broad 50 50.
Let's stop it in the same way.
We will start by a flask service inside of the container using the command python and name of the file
man that boy.
Let's do that here in the command instruction thrust element here in this array will be Python like
that.
And second, one will be parameter, and that is name of the file.
When do I?
And again, such comment by the blast that I will be executed each time.
One container is started.
And notice that here I don't need to specify Python three or any other version of the Python, just
python.
Because here inside of this container, there will be only one part in the version available.
3.9.
And this Python executable points of growth to this version.
3.9.
All right.
This ID for this doggerel file, let's save it.
And let's summarize what happens here on the first line we use base image and despite them, version
3.9 and inside of this image, there was already Python preinstalled along with B.A.P that we need here
in order to install all dependencies.
Next, using work word instruction whispers, a five path working directory inside of the container
and that is folder up.
You could choose any name you want after world using export instruction with withheld that we want to
export brought 50 50.
That is that brought where we were on our Python floor script, cetera.
Next, we copy two files Baby File and Baby File.
Both look from Folder, where our Docker file is located.
It is API folder.
Here are those two files and we compared them to the image to working directory that is fight here.
Isn't this come out?
Next, we run three different commands.
First one to be installed, baby in view and using baby, we installed baby and view package afterwards
using baby envy.
Weekly text file gold requirements data.
Based on those two files and all dependencies of the API service are extracted to the requirements file
and afterward, using kabab, we install all dependencies from this file.
After this moment, inside of the image, there will be all necessary dependencies of our own API application
and they will be installed globally.
We don't create B.A.P in the environment because there is no need for DEP.
Container will be single purpose run python application.
There will be no other applications running this way.
It makes sense to install all the requirements globally inside of the image.
All right, after that, we copy all remaining files from the API folder to the working directory.
It is still up folder inside of the image, and finally, we add, seemed instruction that will run
main file using Python executable inside of the container.
In total, in this Docker file, there are eight steps and the Docker went will build Docker.
Image will go through each instruction one by one step by step.
All right.
Make sure you save the file and then the next lecture of the small bills.
We will build image using this doggerel file.
I'll see you guys next.