Skip to content

remove undocumented top-level "docker remove" command #6144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 19, 2025

Conversation

thaJeztah
Copy link
Member

This was introduced in 9b54d86, which added docker container remove as alias for docker container rm.

However, due to the NewRmCommand being used both for adding the top-level docker rm command and for adding the docker container rm command, it also introduced a (hidden) top-level docker remove command;

docker remove --help | head -n1
Usage:  docker rm [OPTIONS] CONTAINER [CONTAINER...]

The command was not documented, and did not appear in --help output, nor was auto-complete provided;

docker --help | grep remove

docker r<TAB>
rename               (Rename a container)  rm  (Remove one or more containers)  run  (Create and run a new container from an image)
restart  (Restart one or more containers)  rmi     (Remove one or more images)

This patch adds a dedicated, non-exported newRemoveCommand to add sub- commands for docker container, taking a similar approach as was done in moby@b993609d5a for docker image rm.

With this patch applied, the hidden command is no longer there, but the docker rm, docker container rm, and docker container remove commands stay functional as intended;

docker remove foo
docker: unknown command: docker remove

Run 'docker --help' for more information

docker rm --help | head -n1
Usage:  docker rm [OPTIONS] CONTAINER [CONTAINER...]
docker container rm --help | head -n1
Usage:  docker container rm [OPTIONS] CONTAINER [CONTAINER...]
docker container remove --help | head -n1
Usage:  docker container rm [OPTIONS] CONTAINER [CONTAINER...]

Reported-by: Lorenzo Buero 138243046+LorenzoBuero@users.noreply.github.com

- What I did

- How I did it

- How to verify it

- Human readable description for the release notes

Remove an undocumented, hidden, top-level `docker remove` command that was accidentally introduced in docker 23.0

- A picture of a cute animal (not mandatory but encouraged)

This was introduced in 9b54d86,
which added `docker container remove` as alias for `docker container rm`.

However, due to the `NewRmCommand` being used both for adding the top-level
`docker rm` command and for adding the `docker container rm` command, it
also introduced a (hidden) top-level `docker remove` command;

    docker remove --help | head -n1
    Usage:  docker rm [OPTIONS] CONTAINER [CONTAINER...]

The command was not documented, and did not appear in `--help` output,
nor was auto-complete provided;

    docker --help | grep remove

    docker r<TAB>
    rename               (Rename a container)  rm  (Remove one or more containers)  run  (Create and run a new container from an image)
    restart  (Restart one or more containers)  rmi     (Remove one or more images)

This patch adds a dedicated, non-exported `newRemoveCommand` to add sub-
commands for `docker container`, taking a similar approach as was done in
[moby@b993609d5a] for `docker image rm`.

With this patch applied, the hidden command is no longer there, but
the `docker rm`, `docker container rm`, and `docker container remove`
commands stay functional as intended;

    docker remove foo
    docker: unknown command: docker remove

    Run 'docker --help' for more information

    docker rm --help | head -n1
    Usage:  docker rm [OPTIONS] CONTAINER [CONTAINER...]
    docker container rm --help | head -n1
    Usage:  docker container rm [OPTIONS] CONTAINER [CONTAINER...]
    docker container remove --help | head -n1
    Usage:  docker container rm [OPTIONS] CONTAINER [CONTAINER...]

[moby@b993609d5a]: moby/moby@b993609

Reported-by: Lorenzo Buero <138243046+LorenzoBuero@users.noreply.github.com>
Co-authored-by: Lorenzo Buero <138243046+LorenzoBuero@users.noreply.github.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@codecov-commenter
Copy link

codecov-commenter commented Jun 19, 2025

Codecov Report

Attention: Patch coverage is 37.50000% with 5 lines in your changes missing coverage. Please review.

Project coverage is 55.08%. Comparing base (747cb44) to head (19a5c5c).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6144      +/-   ##
==========================================
- Coverage   55.09%   55.08%   -0.01%     
==========================================
  Files         362      362              
  Lines       30265    30268       +3     
==========================================
- Hits        16675    16674       -1     
- Misses      12628    12632       +4     
  Partials      962      962              
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@AkihiroSuda AkihiroSuda merged commit 80d1959 into docker:master Jun 19, 2025
98 of 102 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

missing alias for remove command
3 participants