If you’re just getting started with Docker containers, you may be a bit confused how there doesn’t seem to be a command called “list” to show the containers available on your system. There is ineed no such command, but listing functionality is certainly there.
List currently running Docker containers
You need the docker ps command – it lists containers in a readable table:
Executed without any command line options, docker ps shows only the active containers – the ones running at this very moment.
List all the Docker containers
In case you experience some trouble with one of the containers, where the Docker container will start and immediately go offline, your docker ps won’t help – by the time you run it the container will disappear from the list.
This is where you need to use the –all command line option:
List containers filtered by a specified criteria
You’ll soon realise that on a busy Docker host you probably need to apply some filter when listing containers. This functionality allows you to filter lists by many common Docker container properties.
For example, this is how we can list just the containers with a specific name:
And this is how you can show just the Docker containers with “exited” status:
That’s it for today! Let me know if you’re using Docker and whether you need help with anything!