-: We were just talking about the differences
between starting and creating a container.
Along the way, we ran the command, docker create
and then something like Busy Box echo Hi there.
We then got this printout of the container ID
that was created.
And then we found that we could start up the container
by running Docker start and then pasting the ID in.
However, there is a real little catch to that.
We found that in order to actually see information
being printed out from the container,
we had to add in that dash A flag right there.
So what would happen if you wanted to get
all the output from the container
without having to add in that dash A flag?
For example, let's imagine
that running Docker start like this
was a really expensive process
and we started up a process inside there
that would take many minutes to run.
Chances are if we forgot to add on the dash A flag
to see the output from that,
we might be a little bit frustrated with ourselves
because then we would have to rerun
docker start dash A a second time
and wait another couple minutes.
In order to get around that,
we can make use of an additional command of docker logs.
And then the ID of the container
that we want to get output from.
The logs command can be used to look at a container
and retrieve all the information
that has been emitted from it.
Let's try using that docker, create,
start and then logs command again and seeing what happens.
So I will do Docker create, BusyBox,
and I will echo hi there.
I'll then take that ID and run Docker start
and paste the ID.
That starts up the container.
It executes echo hi there inside of it
and then it immediately exits.
And so now at this point,
I want to go back to that stopped container
and get all the logs that have been emitted inside of it.
So to do so I can run Docker logs
and then paste that ID in.
And I'll see that when the container had been running
it had printed out the string hi there.
One thing to be really clear about
is that by running Docker logs,
I'm not rerunning or restarting the container
in any way, shape or form.
I'm just getting a record of all the logs
that have been emitted from that container.
The docker logs command
is something that we're going to be using quite a bit
as we are trying to debug or set up new containers
because as you can see it's a really good way
to kind of inspect a container
and see what's going on inside of it.
All right.
Still a couple more commands to get through
so let's take another quick pause right here
and continue in the next section.