Now this can of course also be used
to download and run it.
And to see this in action,
I'll first of all run Docker image prune-a
to delete all local images.
And once that is done and we've got no images left,
except for this node image,
which is still around because I started this container
based on this node image a couple of minutes ago,
I would have to delete this container first
in order to be able to delete this image
but let's not worry about this now.
The main thing is that all the other images are missing
and with that, we can now use Docker Pull
to download this image.
Now for that first of all I'll log out
to see whether it also works if I'm not logged in anymore,
and then I'll Docker pull academind node-hello-world
which is that image we just pushed.
It then uses that default tag latest and it downloads it.
And then under Docker images, we can see this.
And since this is public, everyone can pull it.
You don't have to be logged in to do that.
That's why I wanted to show this as well.
You need to be logged into Push to this repository,
but everyone is able to pull.
But this now also means that everyone including you
if you're watching this video right now
is able to Docker pull academind/node-hello-world
and you will then have that image on your system.
And of course you can then use that image
to Docker run academind/node-hello-world.
And that's important.
You need to use the full image name
including academind/.
You can now run this and you can now run this
by exposing the right port for example,
and adding that other removal option.
And of course we could also run this in detached mode
if you want it to.
And with that if I reload local hosts 8,000,
I still see this node app.
So with that, I can Docker stop this container
which I started here like this,
and we're done with that.
But that's how you can share your built images
and not just a Docker File with anyone through Docker Hub
and the repositories you manage there.
But Docker Hub has more features,
it can also help us with deployment,
but for the moment,
this is the key feature you have to know
if you plan on sharing your Docker images with anyone else.
Now, a couple of important notes about pulling and running
your remote images.
Docker Pull, when you execute this command
will always pull the latest image of that name
from your container registry.
So if in the meantime, you will rebuild the image
and push an updated image to the registry
the next time you will execute Docker Pull
will fetch that latest image.
Now you could also run Docker Run
without running Docker Pull first.
If Docker Run doesn't find an image locally on your machine,
it will automatically reach out to the container history,
your image name uses
so here in this case, Docker Hub,
and it will check for the image there.
And if it finds an image of that name there
it will use that and pull that automatically.
What Docker Run will not do though, and that's important
is automatically check for updates.
If you have an image locally
because you pulled or ran it before,
then if you run a container again based on an image,
Docker Run will not check if the image
you have locally on your system
is the latest version of that image.
So if in the meantime,
you updated the image and pushed it again to Docker Hub,
just using Docker Run there after
will not give you that latest updated image.
You instead manually need to run Docker Pull
and then the image name first
to ensure that you have that latest image version
and you then execute Docker Run again.
So it automatically pulls images
but not necessarily the latest version
if you already have that image locally on your system,
because you pulled it before already.