Docker is a popular open-source platform due to its containerization concept. It is used for building and deploying projects. For this purpose, it utilizes Docker images, Docker registries, and Docker containers. Docker containers are the essential part of Docker used to manage, build, and run projects along with their dependencies.
This write-up will illustrate how to list Docker Containers.
How to List Docker Containers?
Sometimes developers or administrative users are required to view containers or check container size or status. For this purpose, you can list down Docker containers using the listed methods:
- Method 1: List All Docker Containers
- Method 2: List Docker Containers With Size
- Method 3: List Latest Containers
- Method 4: List All Containers by Id
- Method 5: List Container in Specific Format
Method 1: List All Docker Containers
To list all Docker containers users can use the “docker container ls” command along with the “-a” option. If the user does not use the “-a” option, then the provided command will show only running containers:
Alternatively, the “docker ps” command is also used to show all containers:
Method 2: List Docker Containers With Size
In order to list down Docker containers as well as their size, the “-s” option is utilized along with the “docker ps” command:
Method 3: List Latest Containers
Users can also view only the latest created containers with the help of the “-l” option as shown below:
Method 4: List All Containers by Id
In order to list view only container id or list down Docker container in quiet mode, utilize the “-q” option along with mentioned command:
Method 5: List Container in Specific Format
Docker users can also list down Docker containers in a format specified using the “–format” option. For instance, we have listed down only container ids and container names:
Alternatively, users can also view the container in a specific format in the form of a table with the help of the given command:
That was all about listing Docker containers.
Conclusion
To list down the Docker containers users can either use the “docker container ls” command or the “docker ps -a” command. These commands also support different options to list containers in different ways, such as “-a” is used to list all containers, “-q” is used to list only container ids, and “–format” is utilized to list containers in a specific format. This write-up has demonstrated how to list Docker containers.