diff --git a/cli/command/container/rm.go b/cli/command/container/rm.go index 171e8e81e9e4..12beef64f6ef 100644 --- a/cli/command/container/rm.go +++ b/cli/command/container/rm.go @@ -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()