8000 #6142 fixed aliases for docker rm --help by LorenzoBuero · Pull Request #6143 · docker/cli · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

#6142 fixed aliases for docker rm --help #6143

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

Closed
wants to merge 1 commit into from

Conversation

LorenzoBuero
Copy link
Contributor
@LorenzoBuero LorenzoBuero commented Jun 19, 2025

fixed typo where the command
$ docker rm --help
doesn't show an alias for "docker remove"

fixed typo where the command
`$ docker rm --help`
doesn't show an alias for "docker remove"

Signed-off-by: LorenzoBuero <138243046+LorenzoBuero@users.noreply.github.com>
@thaJeztah
Copy link
Member

Thanks for contributing!

I need to dig in history, because I wonder if this is actually a bug; to my knowledge we never intended to have a top-level docker remove command; originally docker had docker rm (remove container) and docker rmi (remove image), but when more "object types", such as volumes, networks, etc, arrived, that convention didn't scale well, so we introduced the docker <object> <verb> convention to replace the original top-level commands (docker container rm, docker image rm, docker image list).

For images, I see we added special handling for that; there's a second function that's only used for adding the docker image XXX subcommands, and in that variant the rm and remove aliases are added;

func newRemoveCommand(dockerCli command.Cli) *cobra.Command {
cmd := *NewRemoveCommand(dockerCli)
cmd.Aliases = []string{"rmi", "remove"}
cmd.Use = "rm [OPTIONS] IMAGE [IMAGE...]"
return &cmd
}

So that the top-level (rmi) command would not have aliases that would add a top-level remove command (for images);

cmd := &cobra.Command{
Use: "rmi [OPTIONS] IMAGE [IMAGE...]",
Short: "Remove one or more images",
Args: cli.RequiresMinArgs(1),

The special handling for "image remove" was added in moby/moby@b993609

But it looks like that approach was missed when docker container remove was added as alias for docker container rm in 9b54d86

Looking at the related ticket, it definitely looks like that it was not the intent to add a top-level docker remove command.

At a quick glance, it doesn't look like the remove command appears in --help output, and not in auto-completion;

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)

So, slightly curious how you discovered the command!

@thaJeztah
Copy link
Member

Let me open a PR to fix this

@thaJeztah
Copy link
Member

@LorenzoBuero
Copy link
Contributor Author

Hello thajeztah.
I didn't notice docker remove wasn't documented at all and your observations are very interesting.
About how i found that feature, i mindlesly wrote docker remove because its similar to what i write when using package managers like flatpak.
Then i was making my own documentation for what i have learned and i was writing all the aliases too.

I am happy to have contributed (with such a silly pr) even if it is indirecly, thanks for reading.

@thaJeztah
Copy link
Member

Ah! Heh, so sheer luck to have found it!

I added you as "reporter" and "co-author" in the commit in my PR to give you some credits for contributing 😄 🫶

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0