Skip to content

canceling "docker volume prune" does not consistently print a newline, and exits with non-zero status  #4850

@thaJeztah

Description

@thaJeztah

Description

When terminating docker volume prune using CTRL-C, the CLI terminates, but no newline is printed at the end, causing the shell to continue on the same line. It also exits with a non-zero exit code (255). Behavior is inconsistent between shells though (perhaps some shells compensate for the missing newline, and add them implicitly?).

Reproduce

On Bash on macOS (very old one shipping with macOS);

bash-3.2$ docker volume prune
WARNING! This will remove anonymous local volumes not used by at least one container.
Are you sure you want to continue? [y/N] ^Cbash-3.2$ echo $?
255
bash-3.2$

Using N (don't prune) or ENTER (default: also N), the CLI terminates cleanly with a zero exit-code (but also prints a message, which likely shouldn't be printed 😅);

bash-3.2$ docker volume prune
WARNING! This will remove anonymous local volumes not used by at least one container.
Are you sure you want to continue? [y/N] N
Total reclaimed space: 0B
bash-3.2$ echo $?
0

Interestingly, on a more current version of Bash () on Linux, a newline is printed, but the exit-code is also non-zero, but different (130);

root@debian-s-1vcpu-1gb-ams3-01:~# docker volume prune
WARNING! This will remove anonymous local volumes not used by at least one container.
Are you sure you want to continue? [y/N] ^C
root@debian-s-1vcpu-1gb-ams3-01:~# echo $?
130

root@debian-s-1vcpu-1gb-ams3-01:~# bash --version
GNU bash, version 5.2.15(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

On zsh (default now on macOS), a newline is printed, but also exits with a non-zero exit code;

thajeztah@m1book ~ % docker volume prune
WARNING! This will remove anonymous local volumes not used by at least one container.
Are you sure you want to continue? [y/N] ^C%
thajeztah@m1book ~ % echo $?
255
thajeztah@m1book ~ %

And same for Fish;

 ~  docker volume prune
WARNING! This will remove anonymous local volumes not used by at least one container.
Are you sure you want to continue? [y/N] ^C⏎
 !  ~  echo $status
255
 ~ 

Expected behavior

I expect a newline to be printed, and the command to exit with a zero exit status.

docker version

Client:
 Cloud integration: v1.0.35+desktop.10
 Version:           25.0.1
 API version:       1.44
 Go version:        go1.21.6
 Git commit:        29cf629
 Built:             Tue Jan 23 23:06:12 2024
 OS/Arch:           darwin/arm64
 Context:           desktop-linux

Server: Docker Desktop 4.28.0 (135377)
 Engine:
  Version:          25.0.1
  API version:      1.44 (minimum version 1.24)
  Go version:       go1.21.6
  Git commit:       71fa3ab079ec13d17257f86fa92db8d7f24802f1
  Built:            Wed Jan 24 09:49:39 2024
  OS/Arch:          linux/arm64
  Experimental:     false
 containerd:
  Version:          1.6.27
  GitCommit:        a1496014c916f9e62104b33d1bb5bd03b0858e59
 runc:
  Version:          1.1.11
  GitCommit:        v1.1.11-0-g4bccb38
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

docker info

not relevant

Additional Info

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions