19a5c5c714
This was introduced in 9b54d860cd,
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]: https://github.com/moby/moby/commit/b993609d5ad4590da72e217bb43786b74aabc183
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>
46 lines
1.2 KiB
Go
46 lines
1.2 KiB
Go
package container
|
|
|
|
import (
|
|
"github.com/docker/cli/cli"
|
|
"github.com/docker/cli/cli/command"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
// NewContainerCommand returns a cobra command for `container` subcommands
|
|
func NewContainerCommand(dockerCli command.Cli) *cobra.Command {
|
|
cmd := &cobra.Command{
|
|
Use: "container",
|
|
Short: "Manage containers",
|
|
Args: cli.NoArgs,
|
|
RunE: command.ShowHelp(dockerCli.Err()),
|
|
}
|
|
cmd.AddCommand(
|
|
NewAttachCommand(dockerCli),
|
|
NewCommitCommand(dockerCli),
|
|
NewCopyCommand(dockerCli),
|
|
NewCreateCommand(dockerCli),
|
|
NewDiffCommand(dockerCli),
|
|
NewExecCommand(dockerCli),
|
|
NewExportCommand(dockerCli),
|
|
NewKillCommand(dockerCli),
|
|
NewLogsCommand(dockerCli),
|
|
NewPauseCommand(dockerCli),
|
|
NewPortCommand(dockerCli),
|
|
NewRenameCommand(dockerCli),
|
|
NewRestartCommand(dockerCli),
|
|
newRemoveCommand(dockerCli),
|
|
NewRunCommand(dockerCli),
|
|
NewStartCommand(dockerCli),
|
|
NewStatsCommand(dockerCli),
|
|
NewStopCommand(dockerCli),
|
|
NewTopCommand(dockerCli),
|
|
NewUnpauseCommand(dockerCli),
|
|
NewUpdateCommand(dockerCli),
|
|
NewWaitCommand(dockerCli),
|
|
newListCommand(dockerCli),
|
|
newInspectCommand(dockerCli),
|
|
NewPruneCommand(dockerCli),
|
|
)
|
|
return cmd
|
|
}
|