Skip to content

docker stack ps shouldn't print "Nothing found in stack" to stdout when --format is given #33954

Description

@nhoad

Description

I've got a tool that calls out to docker stack ps --format and attempts to parse the output. If the tool happens to be called for a stack that doesn't exist, then the string "Nothing found in stack: [name]" is printed on standard output, resulting in unparseable output. The exit code is also zero, meaning there's no way to tell short of looking for the literal string "Nothing found in stack".

Steps to reproduce the issue:

$ docker stack ps --format "{{json .Name}}" foo 2>/dev/null
Nothing found in stack: foo
$ echo $?
0
(paste your output here

Describe the results you received:
"Nothing found in stack: foo" appearing on standard output when no stack matching the name "foo" was found with the --format option.

Describe the results you expected:
"Nothing found in stack: foo" appearing on standard error, or nothing at all when no stack matching the name "foo" was found with the --format option.

Additional information you deem important (e.g. issue happens only occasionally):

Output of docker version:

Docker version 17.06.0-ce, build 02c1d87

Output of docker info:

Containers: 4
 Paused: 0                                                                                 
 Stopped: 4                                                                                
Images: 62                                                                                 
Server Version: 17.06.0-ce                                                                 
Storage Driver: overlay                                                                    
 Backing Filesystem: xfs                                                                   
 Supports d_type: true                                                                     
Logging Driver: json-file                                                                  
Cgroup Driver: cgroupfs                                                                    
Plugins:                                                                                   
 Volume: local                                                                             
 Network: bridge host macvlan null overlay                                                 
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog             
Swarm: active                                                                              
 NodeID: qc2o3bj1pvgk5dgqiv8tehf1v                                                         
 Is Manager: true                                                                          
 ClusterID: mamygx5qortkte2jy8d8n7qnu                                                      
 Managers: 3                                                                               
 Nodes: 3                                                                                  
 Orchestration:                                                                            
  Task History Retention Limit: 5                                                          
 Raft:                                                                                     
  Snapshot Interval: 10000                                                                 
  Number of Old Snapshots to Retain: 0                                                     
  Heartbeat Tick: 1                                                                        
  Election Tick: 3                                                                         
 Dispatcher:                                                                               
  Heartbeat Period: 5 seconds                                                              
 CA Configuration:                                                                         
  Expiry Duration: 3 months                                                                
  Force Rotate: 0                                                                          
 Root Rotation In Progress: false                                                          
 Node Address: 10.101.21.24                                                                
 Manager Addresses:                                                                        
  10.101.21.24:2377                                                                        
  10.101.21.25:2377                                                                        
  10.101.21.26:2377                                                                        
Runtimes: runc                                                                             
Default Runtime: runc                                                                      
Init Binary: docker-init                                                                   
containerd version: cfb82a876ecc11b5ca0977d1733adbe58599088a                               
runc version: 2d41c047c83e09a6d61d464906feb2a2f3c52aa4                                     
init version: 949e6fa                                                                      
Security Options:                                                                          
 seccomp                                                                                   
  Profile: default                                                                         
Kernel Version: 3.10.0-514.26.1.el7.x86_64                                                 
Operating System: Red Hat Enterprise Linux                                                 
OSType: linux                                                                              
Architecture: x86_64                                                                       
CPUs: 1                                                                                    
Total Memory: 3.703GiB                                                                     
Name: XXX
ID: KHD2:UXHG:6TVC:DXHG:RXXE:EKLF:VJM4:GGHS:P4OX:LB6H:VQ5H:IFYT                            
Docker Root Dir: /var/lib/docker                                                           
Debug Mode (client): false                                                                 
Debug Mode (server): false                                                                 
Http Proxy: http://proxy.netbox:8080                                                       
Https Proxy: http://proxy.netbox:8080                                                      
No Proxy: localhost,127.0.0.1                                                              
Registry: https://index.docker.io/v1/                                                      
Experimental: false                                                                        
Insecure Registries:                                                                       
 127.0.0.0/8                                                                               
Live Restore Enabled: false                                                                


Additional environment details (AWS, VirtualBox, physical, etc.):

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions