Featured Video Play Icon

How To List All Running Docker Containers

Docker is a popular containerization platform that enables developers to create and manage containers in a consistent and efficient way. One of the essential tasks for developers working with Docker is to list all running containers. In this article, we will walk through how to list all running Docker containers using both the command line and the Docker extension for Visual Studio Code (VSCode).

Lead Developer Career Guide Banner 02

Using the Command Line

Listing all running containers using the command line is a simple process. First, open a terminal window on your machine or you can use VSCode. Run the following command:

docker ps

This command will display all the running containers on your machine along with additional details such as their names, IDs, image names, status, and ports.

If you want to display all containers (including stopped containers), use the -a option:

docker ps -a

This command will display all containers on your machine (running and stopped) along with additional details such as the command used to start the container, the time it was created, and the amount of disk space it is using.

You can also use other command options to customize the output of the docker ps command:

  • -q: This option displays only the container IDs.
  • -n: This option specifies the number of containers to display.
  • -s: This option displays the total file size of all containers.

For example, if you want to display only the container IDs of the running containers, you can use the following command:

docker ps -q

This command will output only the container IDs of the running containers.

Using the Docker Extension for VSCode

If you prefer to use a graphical interface, you can use the Docker extension for VSCode to list all running containers.

To do this, follow these steps:

  1. Install the Docker extension for VSCode if you haven’t already done so.
  2. Click on the Docker extension in the toolbar and expand containers.
  3. You should see list of all the running containers in the Docker explorer panel on the left-hand side of the VSCode window.

You should see a list of all the running containers in the Docker explorer panel on the left-hand side of the VSCode window.

You can click on any container in the list to see more details about it, such as its name, ID, image, status, and ports. You can also stop or remove containers directly from the Docker explorer panel.

Understanding how to list all running Docker containers is a critical task that every developer working with Docker should know how to do. By following the steps outlined in this article, you should now be able to list all running containers on your machine using either the command line or the Docker extension for VSCode. Additionally, you should be familiar with the available command options that you can use to customize the output of the docker ps command.

Learn More About How To List All Running Docker Containers

Tactics and Tools for Troubleshooting Docker on Pluralsight
Tactics and Tools for Troubleshooting Docker – Online Course Available on Pluralsight

If you’re struggling with Docker errors, check out my Pluralsight course, Tactics and Tools for Troubleshooting Docker. This course provides developers with the skills they need to troubleshoot and fix the most common Docker errors. By the end of this course, you will have the skills you need to reduce the time it takes you to assess and fix issues. Click the link below to get started with a free trial today!

Categories: DevOps, DockerTags: