TL;DR
To list docker containers in Linux, you can try these methods:
- Listing Running Containers: Get a quick overview of running containers with essential information like Container ID, Names, Status, and Ports using
docker pscommand. - Displaying Container Details: Inspecting Containers: Access detailed container information in JSON format by using
docker inspect <container_name_or_id>. - Filtering Containers by Criteria: Focus on specific containers based on criteria like status=running with docker ps –filter status=running.
- Sorting and Formatting Output: Customize listing output with specific details using
docker ps --format "ID: {{.ID}}\tName: {{.Names}}\tStatus: {{.Status}}". - Listing Stopped Containers: Cleanup and Maintenance: Identify and remove stopped containers to free up resources with
docker ps -a --filter status=exited.
Listing Docker containers may seem straightforward, but it comes with challenges. Be mindful of common errors like “No Containers Listed,” “Access Denied,” “Unable to Connect to Docker Daemon,” “Container Names vs. Container IDs,” and “Incorrect Filter Syntax.” By familiarizing yourself with these issues, you can navigate Docker more effectively and enhance your container management skills.
Read the guide below to learn different methods to list docker containers in Linux and common errors that can occur during the process.
Docker containers have revolutionized the world of software development, enabling developers to package applications with all their dependencies and run them in isolated environments. Managing these containers efficiently is crucial for ensuring smooth operations and optimal resource utilization. In this comprehensive guide, I will explore different methods to list docker containers in Linux and common errors that can occur while listing containers.
How to List Docker Containers in Linux
To list Docker containers in Linux effectively, use methods like Listing Running Containers for a quick overview, Displaying Container Details for in-depth insights, Filtering Containers by Criteria for focused results, Sorting and Formatting Output for customization, and Listing Stopped Containers for cleanup.
1. Listing Running Containers
When you need a quick overview of all the running containers on your system, listing running containers is the way to go. It helps you monitor active containers and provides essential information like Container ID, Names, Status, and exposed Ports, ensuring efficient management of your containerized applications. Follow these steps:
- Open your Terminal window.

- Enter the following command:
<strong>docker ps</strong> - This command will display essential information about each running container, including its Container ID, Names, Status, and exposed Ports.

2. Displaying Container Details
Sometimes, you may need more detailed information about a specific container. By using the docker inspect command with the Container ID or Name, you can access a JSON representation of the container’s configuration and network settings, aiding in troubleshooting and debugging tasks. To inspect a container, do the following:
- In your command prompt, use the docker inspect command, followed by the Container ID or Name:
<strong>docker inspect container_name_or_id</strong> - The output will provide a JSON representation of the container’s configuration, network settings, and more.

3. Filtering Containers by Criteria
Filtering containers can be incredibly useful when you want to focus on specific containers based on certain criteria. It allows you to focus on relevant containers, such as running or stopped ones, and filter by names or other properties, facilitating effective monitoring and management. Here’s how you can do it:
- Launch your Terminal, use the docker
pscommand with the--filterflag and the desired filter, such asstatus=running:
<strong>docker ps --filter status=running</strong> - This will display a list of containers that are currently running.

4. Sorting and Formatting Output
Customizing the output of your container listing can make it easier to read and focus on specific details. By using the –format flag with a custom Go template, you can display specific container details like Container ID, Name, and Status, making the output more concise and tailored to your needs. Here’s how you can do it:
- Enter your command window and type the following command:
<strong>docker ps --format "ID: {{.ID}}\tName: {{.Names}}\tStatus: {{.Status}}"</strong> - This will format the output to display only the specified information for each container, making it more readable and concise.

5. Listing Stopped Containers: Cleanup and Maintenance
Over time, you may accumulate stopped containers that are no longer needed, consuming valuable resources. Listing stopped containers can help you identify and clean them up efficiently. Follow these steps:
- Open your Terminal and enter the following command: