dockerdocker-swarmdocker-swarm-mode

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"

[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. I want track containers form my swarm service is this possible ?


Solution

  • Id returned by docker service ps my-ngx is the <task_id> To get the container id, you can use docker inspect -f "{{.Status.ContainerStatus.ContainerID}}" <task_id>