[英]Is this possible to get all running containers id's in docker swarm services?
I am newbie in docker swarm mode, If I want more details about my swarm service , from command line I can run docker service ps "service name ", or from docker rest "/v2/services/my-ngx" 我是docker swarm模式的新手,如果我想了解我的swarm服务的更多详细信息,可以从命令行运行docker service ps“服务名”,也可以从docker rest运行“ / v2 / services / my-ngx”
[msreddy@swarmnode1 ~]$ docker service ps my-ngx ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS voj7fllhnmqb my-ngx.1 nginx:latest swarmnode1 Running Running 26 minutes ago
but it didn't give me container id. 但是它没有给我容器ID。 I want track containers form my swarm service is this possible ?
我想从群服务中跟踪容器吗?
docker service ps my-ngx
返回的ID是<task_id>
要获取容器ID,可以使用docker inspect -f "{{.Status.ContainerStatus.ContainerID}}" <task_id>
The Solution of prranay work perfectly. prranay解决方案可以完美地工作。 To put it together with the question asked (bash):
将其与提出的问题(重击)结合在一起:
for f in $(docker service ps -q my-ngx -f desired-state=running);do docker inspect --format '{{.Status.ContainerStatus.ContainerID}}' $f; done
This lists all containers of the mentioned service my-ngx
这列出了提到的服务
my-ngx
所有容器
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.