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
Signed-off-by: Harald Albers <[email protected]>
  • Loading branch information
albers committed Oct 10, 2024
1 parent 88f1e99 commit 147630a
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 147630a

Please sign in to comment.