[英]How to find the pod name given a container ID
Is there a way to find the pod name for a given Docker container ID? 有没有一种方法可以找到给定Docker容器ID的容器名称?
I can do it the other way round "kubectl describe pods" but then I have to run it on all the pods. 我可以用另一种方式围绕“ kubectl描述豆荚”来做,但是然后我必须在所有豆荚上运行它。
Yes, you can get the pod name given a container ID using the following kubectl
request: 是的,您可以使用以下kubectl
请求获得给定容器ID的容器名称:
kubectl get pod -o jsonpath='{range .items[?(@.status.containerStatuses[].containerID=="docker://<container_id>")]}{.metadata.name}{end}' -n <namespace>
where <container_id>
is the long docker container ID and <namespace>
is namespace which we can skip if our pod is in default namespace. 其中<container_id>
是长的docker容器ID,而<namespace>
是命名空间,如果我们的pod在默认命名空间中,则可以跳过。
For example: 例如:
kubectl get pod -o jsonpath='{range .items[?(@.status.containerStatuses[].containerID=="docker://686bc30be6e870023dcf611f7a7808516e041c892a236e565ba2bd3e0569ff7a")]}{.metadata.name}{end}'
nginx-deployment-569477d6d8-xtf42
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.