docker / cli

The Docker CLI
Apache License 2.0
4.97k stars 1.94k forks source link

docker stack ps names not always fully qualified #927

Open remingtonc opened 6 years ago

remingtonc commented 6 years ago

Description

docker stack ps <stackname> and docker ps name outputs are different, namely the fully qualified name is a concatenation of docker stack ps output of format {{.Name}}.{{.ID}} (and sometimes isn't). This inconsistency breaks tooling like docker wait expecting the full name.

This could be looked at several ways... Maybe this is a wontfix and the only workaround is to use the {{.Name}}.{{.ID}} format - if so it should at least be documented/consistent. Maybe docker wait should handle IDs as well as names. etc. etc. Maybe docker stack rm should have a --wait parameter. Or docker stack wait.

Migrating issue from https://github.com/docker/for-mac/issues/2671.

Steps to reproduce the issue:

  1. Create a docker stack
  2. Run docker ps
  3. Run docker stack ps <stackname>

Describe the results you received:

bash-3.2$ docker ps
CONTAINER ID        IMAGE                     COMMAND                  CREATED             STATUS              PORTS               NAMES
df39135ebb6e        arangodb/arangodb:3.3.3   "/entrypoint.sh aran…"   6 seconds ago       Up 1 second         8529/tcp            tdm_dbms.1.ksgwxqovnte08ztelv5e7wncr

bash-3.2$ docker stack ps tdm
ID                  NAME                                IMAGE                     NODE                    DESIRED STATE       CURRENT STATE           ERROR               PORTS
ne974rrd1x6g        tdm_etl.up0g4yhadxlkc6kbrjf41mxy1   tdm_etl:latest            linuxkit-025000000001   Running             Running 6 seconds ago
ksgwxqovnte0        tdm_dbms.1                          arangodb/arangodb:3.3.3   linuxkit-025000000001   Running             Running 7 seconds ago

bash-3.2$ docker wait $(docker stack ps --no-trunc --format "{{.Name}}.{{.ID}}" tdm)
...

Describe the results you expected:

bash-3.2$ docker ps
CONTAINER ID        IMAGE                     COMMAND                  CREATED             STATUS              PORTS               NAMES
df39135ebb6e        arangodb/arangodb:3.3.3   "/entrypoint.sh aran…"   6 seconds ago       Up 1 second         8529/tcp            tdm_dbms.1.ksgwxqovnte08ztelv5e7wncr

bash-3.2$ docker stack ps tdm
ID                  NAME                                IMAGE                     NODE                    DESIRED STATE       CURRENT STATE           ERROR               PORTS
ne974rrd1x6g        tdm_etl.up0g4yhadxlkc6kbrjf41mxy1   tdm_etl:latest            linuxkit-025000000001   Running             Running 6 seconds ago
ksgwxqovnte0        tdm_dbms.1.ksgwxqovnte08ztelv5e7wncr                          arangodb/arangodb:3.3.3   linuxkit-025000000001   Running             Running 7 seconds ago

bash-3.2$ docker wait $(docker stack ps --format "{{.Name}}" tdm)
...

Additional information you deem important (e.g. issue happens only occasionally): Haven't completely validated the docker wait methodology exposed above - looks like sometimes docker stack ps outputs the full name sometimes and a truncated name other times.

Output of docker version:

bash-3.2$ docker version
Client:
 Version:   17.12.0-ce
 API version:   1.35
 Go version:    go1.9.2
 Git commit:    c97c6d6
 Built: Wed Dec 27 20:03:51 2017
 OS/Arch:   darwin/amd64

Server:
 Engine:
  Version:  17.12.0-ce
  API version:  1.35 (minimum version 1.12)
  Go version:   go1.9.2
  Git commit:   c97c6d6
  Built:    Wed Dec 27 20:12:29 2017
  OS/Arch:  linux/amd64
  Experimental: true

Output of docker info:

bash-3.2$ docker info
Containers: 31
 Running: 0
 Paused: 0
 Stopped: 31
Images: 205
Server Version: 17.12.0-ce
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host ipvlan macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: active
 NodeID: up0g4yhadxlkc6kbrjf41mxy1
 Is Manager: true
 ClusterID: cx8l2pivd9rcpuwt55al326wy
 Managers: 1
 Nodes: 1
 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
 Autolock Managers: false
 Root Rotation In Progress: false
 Node Address: 192.168.65.3
 Manager Addresses:
  192.168.65.3:2377
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 89623f28b87a6004d4b785663257362d1658a729
runc version: b2567b37d7b75eb4cf325b77297b140ea686ce8f
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.9.60-linuxkit-aufs
Operating System: Docker for Mac
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 1.952GiB
Name: linuxkit-025000000001
ID: B4QV:JIRY:Y224:6B4S:QQET:NPOJ:CUOK:DUR3:TIXO:CXJU:YQBC:Z4TB
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 36
 Goroutines: 150
 System Time: 2018-03-07T19:08:41.697781Z
 EventsListeners: 2
HTTP Proxy: docker.for.mac.http.internal:3128
HTTPS Proxy: docker.for.mac.http.internal:3129
Registry: https://index.docker.io/v1/
Labels:
Experimental: true
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

Additional environment details (AWS, VirtualBox, physical, etc.): Physical, Laptop, Docker for Mac

dnephin commented 6 years ago

I believe that docker stack ps matches docker service ps. The problem with both of these is that they are poorly named. They actually list swarm tasks, not containers. They should have been called docker stack tasks and docker service tasks.

remingtonc commented 6 years ago

@dnephin TIL. Did not realize stack was an abstraction on service. Will need to research further - will close if this is a needless/invalid issue.