All right.
We just successfully built a Docker image for our API service, and there was a corresponding image
available for use here with this note, please ensure that you are not running API service somewhere
else.
For instance, in Visual Studio Code here, see that there are no protests and there is just single
tap opened.
Also, I am not running API service here.
In this step, I am running on the front end application and I could basically verify that it is not
running here.
Let me open up a new tap and enter local host and report for you.
If you do like that and I see that this site can be reached.
Let's create a new container based on this image, and for that you need to use command Docker run.
Let's run a new container and live export brought using this option and the list by here folding 50.
If you have to own 50 50 in the moment, I'll explain to you what happens here and afterwards will specify
which image we want to use for this particular container.
And you could use either image ID or repository name.
Let's use a repository name, images, gallery API like that, and let's press enter.
And I see that Flask Web server started successfully.
And it is running at broad 50 50.
And I even see such a request that came from the web browser, and it seems that the web browser attempted
to out or refresh this page.
And of course, now when it attempts to access a root URL, I see a response not found.
And the reason why we get here, not found, is that in our flask application, we didn't add any handler
for root, the URL for what's less.
That's why it automatically wrote Don't ask respawn scored four or four.
Not found no.
Let's test our eBay service, and there was only a single API endpoint that we able to test and add
the so-called new image.
Let me go here to when you are a file and here with this end point, so up to throw out a new image.
Let's test it and let's go to web browser.
And here, let's add for what's less.
Basically, I have it here in the dropdown, and let's keep query, Karl.
Let's check whether it works or not.
And yes, I got response from the US place.
It means that now our API service works as before, but now it works inside of the Docker container.
But what is the difference between running this eBay service locally, as we did before and inside is
a Docker container?
Let me demonstrate to you.
Let me open up a new tab here like that and let me again list Docker images, Docker images, and no,
let's create one more container from the same Docker image.
This one image gallery API and belittled and fallen way Docker Run DSP also lets export abroad and heal
this Typekit 50 50 again, same as we did in this example.
50 50 and afterwards article let's type 55 do.
And here let's use same image image gallery API.
Let's press, enter and see what will happen.
And I see error from Docker error response from Daemon Driver or failed programming.
External connectivity on end point by point four four zero 50 50 failed port is already allocated,
and the reason for that is that we are already running one Docker container.
didThe occupies external port 50 50 and difference between those two ports is following this.
Broad is broad that is open inside of the container, and on this broad we run flask API service inside
of the container here.
And now, if you want to access any services inside of the container, you want to bind local port to
external brought on your computer.
And this way we used such option as this be the stealth for published here with specifically local port
on our computer.
And here with bits.
If I brought inside of the container and Docker maps, this external brought on your computer to internal
port of the container.
And this way we were able to access this web page using brought a 50.
This request to our local computer and Docker has brought such a request to this container.
But now, of course, we are not able to reuse same local port on our computers because now it is occupied
by this container.
And this way, now if we want to create one more container from the same image, we need to use another
support.
And let's do that and let's modify probably support from 50 50 dollar, say, 50 51.
You could add here any port you like, but of course, this broad that is brought inside of the container
must remain 50-50 because it is that brought where we start.
Flask Web server.
All right.
Let's now try to run this container run.
And I see that the Flask Web server started.
And here I see exactly the same log as in this output because internally inside of the Container Flask
web server is running at the same port brought 50 50.
But now we expose those flask web servers to different external boards on our computers, and we could
now test it in a web browser.
Let me copy this URL Gordon UTEP wasted here, but no, I will change this port 55 to two Port 5:51
Like this?
Let's now see what we'll get, and I get response from the bliss.
And now this request was processed by this second container.
Here you see two different requests.
One request to the new image and point and another one for federal by the cone, of course, was not
found and the server returned code four or four because we didn't add the Vatican in the flask web.
Cetera, but you got an idea.
Now we are able to process a request in both containers and you could create as many containers as you
like.
All of them will perform same operations because all of them are running exactly the same code base.
And now, in order to run API service, we basically don't require those files in our images gallery
folder.
I mean, API subfolder and others, you could simply delete them and use only Docker images.
This how it works.
All those files, including, for instance, may end up by a file e needed local file, even all located
inside.
There was a Docker image because here on this line, we actually corbet all application files to the
image, and now you're able to reuse it multiple times and create different containers.
All right.
Let's no stop this second container.
We don't need it anymore.
And no, if I anti-Europeans repeals, I'll see only one container does running.
And here was binding of the ports.
We bind a local a port on our computers 550 to port, 50:50 inside of the container.
He was command that was executed by the man to try this container was created 13 minutes ago.
He was container idea and he was image that was used for running of this container.
Of course, if I try to access this, you're now using 40, 50 51.
I'll get this side can be reached because no second container is stopped and we are not able to access
it anymore.
But we are still able to access this URL at brought 50 50, and here was another response on Splish.
And this response was settled again by this container here with this request.
All right.
Let's know of the small pause explore contents of this container.
And for that, we will open best session to the container and analyze structure of the file system inside
of that container.
I'll see you guys just in a bit.