# How to List all Containers Running in a Cluster

## Problem

View all the containers runnings inside a cluster.

## Environment

* Platform9 Managed Kubernetes - All Versions
* kubectl

## Procedure

1. Download the kubeconfig for the cluster you want the information for.
2. Save the kubeconfig at the following path *\~/.kube/config* or run the kubectl command with the *--kubeconfig=* command
3. Run the following command to get a list and number of running containers of each type.

{% tabs %}
{% tab title="Bash" %}

```bash
kubectl get pods --all-namespaces -o jsonpath="{.items[*].spec.containers[*].name}" | tr -s ' ' '<br>' |sort |uniq -c
```

{% endtab %}
{% endtabs %}

## Additional Information

You can obtain other information about the containers by changing the *spec.* value. For example you can get a list and number of all images running in a cluster by running the above command with *`spec.containers[*].image`.*


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://platform9.com/kb/pmk/how-to/how-to-list-all-containers-running-in-a-cluster.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
