How to list all running & stopped Docker containers

Docker is the popular platform to run container virtual machines using the pre-built app images. The installation and its usage are pretty simple, yet, if you are new to it and want to know how to list all the created or stopped Docker containers to delete or manage them easily. Then here are the commands to follow.

Command to list the docker containers

docker ps —option

–all , -a Show all containers (default shows just running)
–filter , -f Filter output based on conditions provided
–format Pretty-print containers using a Go template
–last , -n -1 Show n last created containers (includes all states)
–latest , -l Show the latest created container (includes all states)
–no-trunc Don’t truncate output
–quiet , -q Only display container IDs
–size , -s Display total file sizes

To show only running containers

If you are running multiple Docker containers but want to list only those that are currently active and running then on your command terminal- type:

docker ps
or
docker container ls

This will all of the active containers along with other information

command to sahow only running docker container

 

List all running and stopped containers

Well, to show all running containers along with those that are created by you earlier but have not been active anymore, we can use -a option with docker’s ps command.

docker ps -a

command list all stopped and runnin docker containers

 

To show the latest created container

If we have a long list of containers but want to see only the latest created ones, then use:

docker ps -l

Show only newly created containers

 

List last ‘n’ created containers

docker ps --last -1

last n created containers list

 

To display total file sizes

docker ps -s

show size of all docker containers

 

These were some simple options to use with the Docker PS command. For more details see the official documentation.

 

 

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.