Skip to content

Commit 320259d

Browse files
authored
Merge pull request #29418 from Arhell/fix
[zh] Fix list all uniq container images
2 parents 87235b5 + f086aba commit 320259d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

content/zh/docs/tasks/access-application-cluster/list-all-running-container-images.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ of Containers for each.
3636
3737
- Fetch all Pods in all namespaces using `kubectl get pods --all-namespaces`
3838
- Format the output to include only the list of Container image names
39-
using `-o jsonpath={..image}`. This will recursively parse out the
39+
using `-o jsonpath={.items[*].spec.containers[*].image}`. This will recursively parse out the
4040
`image` field from the returned json.
4141
- See the [jsonpath reference](/docs/user-guide/jsonpath/)
4242
for further information on how to use jsonpath.
@@ -48,7 +48,7 @@ of Containers for each.
4848
## 列出所有命名空间下的所有容器
4949

5050
- 使用 `kubectl get pods --all-namespaces` 获取所有命名空间下的所有 Pod
51-
- 使用 `-o jsonpath={..image}` 来格式化输出,以仅包含容器镜像名称。
51+
- 使用 `-o jsonpath={.items[*].spec.containers[*].image}` 来格式化输出,以仅包含容器镜像名称。
5252
这将以递归方式从返回的 json 中解析出 `image` 字段。
5353
- 参阅 [jsonpath 说明](/zh/docs/reference/kubectl/jsonpath/)
5454
获取更多关于如何使用 jsonpath 的信息。
@@ -58,7 +58,7 @@ of Containers for each.
5858
- 使用 `uniq` 来聚合镜像计数
5959

6060
```shell
61-
kubectl get pods --all-namespaces -o jsonpath="{..image}" |\
61+
kubectl get pods --all-namespaces -o jsonpath="{.items[*].spec.containers[*].image}" |\
6262
tr -s '[[:space:]]' '\n' |\
6363
sort |\
6464
uniq -c
@@ -132,7 +132,7 @@ following matches only Pods with labels matching `app=nginx`.
132132
要获取匹配特定标签的 Pod,请使用 -l 参数。以下匹配仅与标签 `app=nginx` 相符的 Pod。
133133

134134
```shell
135-
kubectl get pods --all-namespaces -o=jsonpath="{..image}" -l app=nginx
135+
kubectl get pods --all-namespaces -o=jsonpath="{.items[*].spec.containers[*].image}" -l app=nginx
136136
```
137137

138138
<!--
@@ -146,7 +146,7 @@ following matches only Pods in the `kube-system` namespace.
146146
要获取匹配特定命名空间的 Pod,请使用 namespace 参数。以下仅匹配 `kube-system` 命名空间下的 Pod。
147147

148148
```shell
149-
kubectl get pods --namespace kube-system -o jsonpath="{..image}"
149+
kubectl get pods --namespace kube-system -o jsonpath="{.items[*].spec.containers[*].image}"
150150
```
151151

152152
<!--

0 commit comments

Comments
 (0)