
Listing containers
As we continue to run containers over time, we get a lot of them in our system. To find out what is currently-running on our host, we can use the container list command as follows:
$ docker container ls
This will list all currently-running containers. Such a list might look similar to this:

By default, Docker outputs seven columns with the following meanings:

If we want to list not only the currently running containers but all containers that are defined on our system, then we can use the command-line parameter -a or --all as follows:
$ docker container ls -a
This will list containers in any state, such as created, running, or exited.
Sometimes, we want to just list the IDs of all containers. For this, we have the parameter -q:
$ docker container ls -q
You might wonder where this is useful. I show you a command where it is very helpful right here:
$ docker container rm -f $(docker container ls -a -q)
Lean back and take a deep breath. Then, try to find out what the preceding command does. Don't read any further until you find the answer or give up.
Right: the preceding command deletes all containers that are currently defined on the system, including the stopped ones. The rm command stands for remove, and it will be explained further down.
In the previous section, we used the parameter -l in the list command. Try to use Docker help to find out what the -l parameter stands for. You can invoke help for the list command as follows:
$ docker container ls -h