In this section we're going to take another look at a very commonly used command.
It's the command that we're going to look at is Docker.
P.S. This command will list all the different running containers that are currently on your machine.
Let's try running it right now and just see what happens.
I'll flip on over to my terminal and I'll run Docker.
P.S. When I run this command you're going to see some headers for a table.
At present we have no containers running our machine.
So we have no entries inside this table at this point.
We've only been running images or creating containers that run very quickly and then immediately closed
down.
So for example when we were running Docker run a Busy Box and echo Hi there.
That container starts up and then almost immediately exits us back to the command line.
So if we want doctored piece to be meaningful at all we have to have some container that is running
for some longer amount of time in order to get a container running a little bit longer.
We could substitute the command that is executed when that container starts up.
So rather than running echo HI THERE I'LL TRY IT Docker run Busy Box and then I'll do ping Google dot
com.
This is a command that's going to attempt to ping Google's servers and measured the amount of latency.
It's a command that's going to continue running for a quite a long time.
So here it is running right here.
And as you can see it takes about two or three milliseconds for me to ping Google and get a response
back.
This command is going to continue running so we can now run a darker P.S. In a second window and we
should see this container up here in the listing.
I'm going to open up a second terminal window and then I'll execute Docker.
Yes.
And when I do so I'll then see that running container.
I'm going to get this on one line really quickly.
There we go.
So this is a print up for the container that is currently running.
That was issued the command of Ping Google dot com.
We also see the containers I.D. which we can use for a lot of other operations it will look in to later
on we'll see the image that was used for the container.
We can see how long ago it was created.
We get a status currently it's been up for 24 seconds.
We'll see a listing of any ports that have been opened for outside access.
And we're going to talk a lot about ports later on inside this course and at the very end.
We'll also see a randomly generated name to identify this container in my case the randomly generated
name was epic.
Corey if I now flip back over to that running ping process I can press control see on my keyboard to
stop it so press control see right now and I get kicked back to my command line as you might expect.
If I then run Docker P.S. the second time I would not see that container anymore.
So Dr. P.S. specifically shows running containers we can modify the docker P.S. command just a little
bit to show all containers that have ever been created on our machine to do so we can execute Docker.
P.S. dash dash all just two dashes.
There we go when we execute that command we'll see a listing of all the containers that we have ever
created.
That's going to zoom out again.
Again here really quickly just so I can see this table.
There we go.
So for every one of these containers these have all been containers that we have started up and then
have either been shut down on our behalf or shut down naturally.
So for each one of them we'll see the container I.D. image command when it was created its current status.
In this case they're all exited any ports that have been opened up again we'll talk about those later
and the randomly generated name for each one so in practice.
We're going to end up using the docker P.S. command quite a bit to see what containers are currently
running on our machine.
One of the most common uses of Docker P.S. is not only to see what's running but also to get the idea
of a running container because like I said we very frequently want to issue commands on a very specific
container.
And for that we need its I.D..
All right.
So that's a talker yes command.
Let's take a quick pause right here and continue in the next section.