docker / docker/cli

docker service create prints progress-bars on stdout instead of stderr

Open
#1,647 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area/swarm area/ux kind/enhancement
Dominant language
Go
Stars
6.1k
Forks
2.2k
Avg merge
1d 15h
Merged PRs (30d)
43

Description

Description

I noticed that docker service create prints the progress-bars on stdout instead of stderr;

docker service create nginx:alpine 2> /dev/null
clu6qi8pcg2fbnhxpuusdk0iw
overall progress: 1 out of 1 tasks
1/1: running   [==================================================>]
verify: Service converged

Because of this, it's not possible to redirect the progress information, and still use the printed id for scripting;

docker service create nginx:alpine 2> /dev/null | xargs docker service ps
ID                  NAME                IMAGE               NODE                DESIRED STATE       CURRENT STATE           ERROR               PORTS
yy1ra43a6r10        cranky_poincare.1   nginx:alpine        docker-desktop      Running             Running 5 seconds ago                       
no such service: overall
no such service: progress:
no such service: 0
no such service: out
no such service: of
no such service: 1

Using --detach disables the progress bars, so works as a workaround;

docker service create --detach nginx:alpine 2> /dev/null | xargs docker service ps
ID                  NAME                 IMAGE               NODE                DESIRED STATE       CURRENT STATE                    ERROR               PORTS
l07wdom4zwlt        gifted_chebyshev.1   nginx:alpine                            Running             Pending less than a second ago          

Describe the results you received:

$ docker service create nginx:alpine 2> ./err.log
clu6qi8pcg2fbnhxpuusdk0iw
overall progress: 1 out of 1 tasks
1/1: running   [==================================================>]
verify: Service converged

$ cat err.log 
# empty

Describe the results you expected:

$ docker service create nginx:alpine 2> ./err.log
n8ed2qh8g6yi4d1ofi3kn7n16

$ cat err.log 
overall progress: 0 out of 1 tasks
1/1:  
overall progress: 0 out of 1 tasks
overall progress: 1 out of 1 tasks
verify: Waiting 5 seconds to verify that tasks are stable...
verify: Waiting 4 seconds to verify that tasks are stable...
verify: Waiting 3 seconds to verify that tasks are stable...
verify: Waiting 2 seconds to verify that tasks are stable...
verify: Waiting 1 seconds to verify that tasks are stable...
verify: Service converged

Output of docker version:

Client: Docker Engine - Community
 Version:           18.09.1
 API version:       1.39
 Go version:        go1.10.6
 Git commit:        4c52b90
 Built:             Wed Jan  9 19:33:12 2019
 OS/Arch:           darwin/amd64
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          18.09.1
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.6
  Git commit:       4c52b90
  Built:            Wed Jan  9 19:41:49 2019
  OS/Arch:          linux/amd64
  Experimental:     true

Output of docker info:

not relevant

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the docker service create command entry point and reproduce the reported stdout/stderr behavior using the redirection examples. Done means the service ID remains on stdout while progress and verification output go to stderr, without changing the --detach workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, go
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.