Docker Community Forums

Share and learn in the Docker community.

Get current service replicas via Docker API

swarm

(Bhartm3) #1

I’m trying to get the current replica status of a service in the swarm. So far I only found

  "Mode": {
                "Replicated": {
                    "Replicas": 10
                }

in the /services GET which is the desired amount of replicas but not current. Is there a place in the API that provides this info like in:

# docker service ls
ID                  NAME                                     MODE                REPLICAS            IMAGE   PORTS
klp0m5vt2h4s        image1   replicated          10/10               registry.xy.com/image1   

Thank you!


(Caub) #2

I created this issue https://github.com/moby/moby/issues/38283

if the API with tasks and filters query work correctly, this could give the number of tasks running for a service and the total tasks for a service. This is what docker service ls command does https://github.com/docker/cli/blob/master/cli/command/service/list.go#L111