How to list all the docker containers?

list all docker containers in system

To list all the running docker containers, use this command –

docker ps

and use this command to list all the containers running or otherwise

docker ps -a

Different Container States

Suppose no container is running in your system, then docker ps command will return an empty table as shown in the image –

docker ps (no container running)
docker ps (no container running)

In this situation we might need to know about all the containers which are stopped. docker ps -a will return all of them, no matter whether they are running or stopped. Check out the image below –

docker ps -a (no container running)
docker ps -a (no container running)

You can see that the command displayed a list of many containers. They are all in exited state.

If a container is running then the outputs are –

For docker ps

docker ps (container running)
docker ps (container running)

For docker ps -a

docker ps -a (some containers running)
docker ps -a (some containers running)

Understanding Response

Let us understand the response return by the command. It’s a table of columns –

  1. CONTAINER ID – This is a 12 digit unique alphanumeric id which is assigned by docker to each container. This id is used to start/stop a container.
  2. IMAGE – It’s the name of the image for which the container is running.
  3. COMMAND – This is the entrypoint command which is listed in Dockerfile of image. This command runs when a container gets live.
  4. CREATED – This shows the time when the container was created.
  5. STATUS – The current status of container (Up or Exited). Along with that it shows the time when it attained this status.
  6. PORTS – The ports which are exposed in the container.
  7. NAMES – A human readable name for container. You can do everything using this name what you can do with container id.

Sign Up for Our Newsletters

Get only the best articles delivered to your mail

You May Also Like