Skip to content

Commit

Permalink
Only complete removable containers if --force is not given
Browse files Browse the repository at this point in the history
  • Loading branch information
albers committed Oct 10, 2024
1 parent 88f1e99 commit 475be86
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cli/command/container/rm.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ func NewRmCommand(dockerCli command.Cli) *cobra.Command {
Annotations: map[string]string{
"aliases": "docker container rm, docker container remove, docker rm",
},
ValidArgsFunction: completion.ContainerNames(dockerCli, true),
ValidArgsFunction: completion.ContainerNames(dockerCli, true, func(ctr container.Summary) bool {
return opts.force || ctr.State == "exited" || ctr.State == "created"
}),
}

flags := cmd.Flags()
Expand Down

0 comments on commit 475be86

Please sign in to comment.