@@ -27,10 +27,9 @@ func NewRmCommand(dockerCli command.Cli) *cobra.Command {
2727 var opts rmOptions
2828
2929 cmd := & cobra.Command {
30- Use : "rm [OPTIONS] CONTAINER [CONTAINER...]" ,
31- Aliases : []string {"remove" },
32- Short : "Remove one or more containers" ,
33- Args : cli .RequiresMinArgs (1 ),
30+ Use : "rm [OPTIONS] CONTAINER [CONTAINER...]" ,
31+ Short : "Remove one or more containers" ,
32+ Args : cli .RequiresMinArgs (1 ),
3433 RunE : func (cmd * cobra.Command , args []string ) error {
3534 opts .containers = args
3635 return runRm (cmd .Context (), dockerCli , & opts )
@@ -50,6 +49,15 @@ func NewRmCommand(dockerCli command.Cli) *cobra.Command {
5049 return cmd
5150}
5251
52+ // newRemoveCommand adds subcommands for "docker container"; unlike the
53+ // top-level "docker rm", it also adds a "remove" alias to support
54+ // "docker container remove" in addition to "docker container rm".
55+ func newRemoveCommand (dockerCli command.Cli ) * cobra.Command {
56+ cmd := * NewRmCommand (dockerCli )
57+ cmd .Aliases = []string {"rm" , "remove" }
58+ return & cmd
59+ }
60+
5361func runRm (ctx context.Context , dockerCLI command.Cli , opts * rmOptions ) error {
5462 apiClient := dockerCLI .Client ()
5563 errChan := parallelOperation (ctx , opts .containers , func (ctx context.Context , ctrID string ) error {
0 commit comments