How to list all running & stopped Docker containers – Linux Shout

Npressfetimg 547.png

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

 

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

 

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

 

List last ‘n’ created containers

docker ps --last -1

 

To display total file sizes

docker ps -s

 

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

 

 

Source: https://www.how2shout.com/linux/how-to-list-all-running-stopped-docker-containers/


Leave a Reply

Your email address will not be published. Required fields are marked *