Docker ps Command Explained with Examples

Photo of author

By Victor Ashiedu

Published

Have you seen the Docker ps command and wondered what it does and how to use it? Join me in this short guide as I explain this all-important Docker command.

Overview, Command Syntax, and Options

As you create Docker containers, over time you have a number of them. Moreover, from time to time, you may need to view the containers to get information about them.

This is where the Docker ps command comes in.

This simple command is used to list containers previously started on the local computer.

Why will you want to list containers on the computer?

There are multiple reasons. Firstly, you may want to get the container ID, name or the ports it is mapped to the host.

Getting the ID or name of a stopped container is useful for starting it. We will see how to start a stopped container in the examples section of this guide.

Usage and Options of the Docker ps Command

To see the usage and options of the Docker ps command, run the command with the “–help” option.

docker ps --help

See the result of the command in my screenshot below.

Usage and Options of the docker container list Command

As I explained earlier in the guide, we can see that this lists existing Docker containers. In addition to that, it also shows the aliases of the command.

Essentially, the commands – “docker container ls,”docker container list,” “docker container ps” – are the same as “docker ps.”

So, you can use any of the listed commands instead of the common command.

Moving down the result of the help page, you see the available options. When I published this guide in February 2024, the “Docker ps” command had 6 options.

However, I like to highlight the two commonly used options – “-a” or “–all” and “-f.” As you will see in the examples section, when you work with Docker containers you will find the “-a” or “–all” of the “Docker ps” command useful.

This is because it is used to display both running and stopped containers. When you run the “ps” command without the “-a” option, it only returns running containers.

So, if you want to list all containers – including stopped containers – use this option.

Another common parameter is “-f.” This is essentially a search option used to return containers that meet the conditions you specify.

Docker ps Command Examples

Now that we have explained what this Docker command is all about, let’s see how to use it.

As I already hinted, if you run the command without any parameters, it lists only containers that are currently started (STATUS is “Up”).

docker ps

When I ran the command on my Windows computer, it listed two containers.

docker container ls Examples

But what is I want to see all containers? I will simply include the “-a” or “–all” option as shown in this command.

docker ps -a

I have a long list of containers – most of them stopped or “exited.”

This is not a very pretty list – it is too long!

How about using the “-f” option to list only the containers I need? Let’s say I want to list mysql containers, I will use the command below.

docker ps -a -f name=mysql
list docker containers

How about listing all stopped containers? We can do that too using the “-f status=exited.”

docker ps -f status=exited
The -f option accepts a key=value pair input. For a full list of the keys you can use with this option, see the Filtering (–filter) section of the official Docker document for this command.

Before you go, it is worth showing the aliases of the “Docker ps” command in action. See the screenshot below for how I used the aliases of the commands I used in this guide so far.

docker container ls,docker container listdocker container ps

Finally, to start a container that isn’t currently running use the “Docker start” command. The command accepts the container name or ID.

Frequently Asked Questions

1. What does ps do in Docker?

Running the “Docker ps” command lists containers.

2. Where to run the Docker ps command?

Run this command on a terminal. Note that Docker must be installed and the daemon running on the local computer to run a Docker command, including the “ps” command.

3. How do I see all Docker Containers?

Run the “Docker ps” command with the “-a” option. This option lists running and stopped (“exited”) containers.

4. How do I connect to a Docker Container?

To connect (open a terminal) to a Docker container, run the Docker Exec command.

5. How do I view Docker images?

To view docker images on your downloaded (pulled) to your computer, run the “Docker images” or “Docker images ls” command.

Conclusion

I hope you enjoyed reading the guide and now know how to use this essential Docker command.

We like to hear from you.

Kindly share your feedback or ask a question using the comments form at the bottom of this page.

Alternatively, you can respond to the “Was this page helpful?” question below.

About the Author

Photo of author

Victor Ashiedu

Victor is the founder of InfoPress Media, publishers of Ilifeguides and Itechguides. With 20+ years of experience in IT infrastructure, his expertise spans Windows, Linux, and DevOps. Explore his contributions on Itechguides.com for insightful how-to guides and product reviews.

Related Articles

Get in Touch

We're committed to writing accurate content that informs and educates. To learn more, read our Content Writing Policy, Content Review Policy, Anti-plagiarism Policy, and About Us.

However, if this content does not meet your expectations, kindly reach out to us through one of the following means:

  1. Respond to "Was this page helpful?" above
  2. Leave a comment with the "Leave a Comment" form below
  3. Email us at [email protected] or via the Contact Us page.

Leave a comment

Send this to a friend