Now it's just a first example,
there is more you can and should find
if you really would want to have this up and running,
for example, connect your own custom domain.
But as I said,
that is something you can do with help
of the official AWS docs,
because this will not be the final way
of deploying something we'll have a look at
in this module.
Because you might have more complex applications
and also different needs for your deployment process.
Still it's a first example,
and it is our application up and running
and you therefore hopefully see why Docker is awesome
and how it can help us during development,
but then also for deployment.
Now still to finish up this example,
let me show you how you could push updates to your code,
to that remote server and how you can then stop
and shut everything down if you want that to do that.
So let's start with updating the code.
I'll make a very simple change here.
I add a bunch of exclamation marks here
in the welcome HTML file after this works.
Now, of course this change is not automatically reflected
on the remote server.
There we still see the old version
because I only made that change locally.
Now, the process of bringing these updates
to the remote server is simple, though.
We rebuild the image push it to Docker Hub again,
and make sure we use this updated image
on the remote server.
So therefore here on my local machine,
in the terminal, running on my local machine,
I rebuild my node-dep-example-1 image,
which now takes into a updated source code.
I then tag it appropriately.
And then we, again push this now updated image
to Docker Hub.
And you see it's pushing this in a very efficient way,
only pushing the parts that really changed
and reusing the layers that didn't change.
Now, once we did that, we can switch to the terminal,
which is connected to the EC2 instance.
And there I will first of all,
list all running containers
and then stop this container which we started before
with sudo docker stop and then the container name.
So now this stops this container on the remote machine,
and then we wanna rerun it based on this updated image.
So therefore once it's stopped,
we can repeat this sudo docker run command,
but you will notice that if we do that in reload,
we still see the old version.
The reason for that is that
whenever you docker run an image, Docker always just checks,
whether it already has this image locally.
And if it does it just uses that.
It does not check,
if there is a more up-to-date remote image available.
To ensure that we do use the latest version though,
we can run docker pull manually
and simply pull this image again.
This will now pull the latest version
and therefore our updated version.
And once we did this,
we can shut down this container we just started,
which still uses the old version.
But now that we pulled the latest version with docker pull,
when we run docker run the next time,
this latest version will be used.
So once this stopped, we can now run docker run again.
And because we pulled the latest version manually,
now that latest version is up and running.
And hence, if I reload here,
I see all the exclamation marks.
And that is how you could update your deployed code.
By simply rebuilding the image,
pushing it again, pulling, and then rerunning the container.
Now, if you ever want to shut everything down
or you temporarily wanna pause this instance here,
you can of course use docker stop to stop your container.
And if we do this,
for this container we just started again,
you will of course see that once this is stopped,
which it is now.
Reloading this webpage will fail
because there is no running web server
on this EC2 instance anymore.
Because we just stopped it.
Now you can always restarted with docker run again,
or if you wouldn't remove stop containers
all with docker start.
But if you wanna shut down your EC2 instance forever,
you can do this from inside the EC2 dashboard.
There under instances,
simply make sure you select the instance
which is running your remote dockerized application
and under actions, choose Instance State, Terminate.
And this now really deletes the entire instance
and the application running on it.
And I'll do this here because this was a nice first example
and a possible way of deploying a Docker application.
But it will not be the final way
of deploying an application with Docker.
Because it turns out that this approach,
which has showed you in great detail here,
has a couple of disadvantages and downsides.