for-aws icon indicating copy to clipboard operation
for-aws copied to clipboard

docker ps <service> lists tasks for all services starting with service name <service>

Open Deepak-Vohra opened this issue 7 years ago • 3 comments

Expected behavior

Only tasks for a specific service be listed.

Actual behavior

Tasks for all services starting with the specified service name get listed.

Steps to reproduce the behavior

  1. ...Create two services (any arbitrary Docker services) with one with suffix -2. For example, two services mysql and mysql-2.
  2. ...The docker service ps mysql command lists tasks for both the services mysql and mysql-2.
~ $ docker service ls
ID                  NAME                MODE                REPLICAS            IMAGE               PORTS
likujs72e46t        mysql               replicated          3/3                 mysql:latest        
ocd9sz8qqp2b        mysql-2             replicated          3/3                 mysql:latest        
~ $ docker service ps mysql
ID                  NAME                IMAGE               NODE                            DESIRED STATE       CURRENT STATE            ERROR               PORTS
c2ckhyi0rmry        mysql-2.1           mysql:latest        ip-172-31-47-15.ec2.internal    Running             Running 11 minutes ago                       
v4bn24seygc6        mysql.1             mysql:latest        ip-172-31-47-15.ec2.internal    Running             Running 29 minutes ago                       
wnr3x7khz9vg        mysql-2.2           mysql:latest        ip-172-31-47-123.ec2.internal   Running             Running 7 minutes ago                        
29702ebj52gs        mysql.2             mysql:latest        ip-172-31-47-123.ec2.internal   Running             Running 27 minutes ago                       
f0112rfzt1cd        mysql-2.3           mysql:latest        ip-172-31-3-168.ec2.internal    Running             Running 7 minutes ago                        
c7b8v16msudl        mysql.3             mysql:latest        ip-172-31-3-168.ec2.internal    Running             Running 27 minutes ago         

Deepak-Vohra avatar Jul 26 '17 19:07 Deepak-Vohra

This isn't docker for aws specific, probably best to add this issue to one of the upstream repos, maybe https://github.com/moby/moby is the right place?

It looks like docker service ps is using a wildcard search. There is probably a way to make it more rigid with it's results. For more info about docker service ps, including how to best to search and format the output, check out: https://docs.docker.com/engine/reference/commandline/service_ps/

kencochrane avatar Jul 26 '17 20:07 kencochrane

docker service ps is supposed to be for the specified service. Even enclosing service name in quotes docker service ps "mysql" lists all tasks for service name starting with "mysql"

Deepak-Vohra avatar Jul 26 '17 20:07 Deepak-Vohra

Copying here as well; this is a duplicate of https://github.com/moby/moby/issues/32556 and already fixed on master through https://github.com/docker/cli/pull/72 (which will be included in docker 17.06.1)

thaJeztah avatar Jul 27 '17 00:07 thaJeztah