Now I'm back in the demo project
we worked on before,
and I'll bring up that built-in terminal again.
But you can of course also open up
a default terminal outside of Visual Studio code.
And there we got various commands which we can run
with help of the Docker command.
And as I mentioned,
if you for example run docker --help,
you get a list of the built-in main commands
you can run with Docker.
And you see there are quite a lot of commands there.
Well, good news is a lot of these commands
will not really matter to you in the vast majority of cases.
There also are some commands from the past
where we nowadays have better ways of achieving something.
But still, you see we have quite a lot of commands here.
You can obviously read these descriptions
to see what these commands do,
but it will come down to a couple of core commands
you should be aware of.
In addition, there also are some commands which also
could be replaced by other commands executed differently.
In general, with Docker for some operations
you have multiple ways of performing that operation.
Now I wanna start with managing images and containers
since that is what Docker is all about.
And we already saw for example
that you can list all containers by running docker ps.
And this shows you all running containers by default.
Now if you add -a,
you see all containers you had in the past
including the stopped containers
which are not running anymore.
As a side note, if you run docker ps --help,
you see all available config options for docker ps.
And here's the -a flag which we used to show all containers.
So docker ps -a shows us all containers,
including the containers we stopped.
And one important thing you can also do with Docker
is you can restart a stopped container.
You don't always need to docker run a new container,
because that's important.
With docker run, you create a new container
based on an image,
and that new container is started thereafter.
Sometimes that is what you want but sometimes it's not.
If nothing changed about our application,
about the dependencies and our source code,
and our image didn't change,
there is no need to create a brand new container.
We can just restart an existing container.
And for that we can just search for stopped containers
with docker ps -a.
Now you might see a different output than I do here
because I'm also working with these containers off screen,
deleting some which we'll learn later and adding new ones.
But here you see my history of Docker containers
I worked with recently.
And if nothing changed about our code
and about our Docker file,
we can just grab let's say this one,
the most recent one which exited
and restart that with docker start.
If we run docker start and then the container ID or name,
this will bring the container back up.
Now you'll see it starts the container in a different mode.
It's not blocking the terminal as it did with docker run,
but I can tell you this container is up and running.
And you can verify by running docker ps
without the -a flag to only see the running containers.
And you should see this container here.
And we can also visit localhost 3000 and reload there.
And there our application is up and running,
thanks to this restarted container.
But again, as I mentioned,
this restarted container is in this strange mode where,
yes, it did start.
But no, we're not really able to interact with it
or to see the logs.
Instead, it started this container
and then returned to the terminal
so that we could enter more commands.
And as I mentioned, that's different to what docker run did.
Well, that's something we're going to explore next.