diff --git a/cli/command/container/completion.go b/cli/command/container/completion.go index f988d2c0c1..23a1dedfd7 100644 --- a/cli/command/container/completion.go +++ b/cli/command/container/completion.go @@ -75,6 +75,11 @@ func addCompletions(cmd *cobra.Command, dockerCLI completion.APIClientProvider) _ = cmd.RegisterFlagCompletionFunc("volumes-from", completion.ContainerNames(dockerCLI, true)) } +// completeDetachKeys implements shell completion for the `--detach-keys` option of `run` and `create`. +func completeDetachKeys(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) { + return []string{"ctrl-"}, cobra.ShellCompDirectiveNoSpace +} + // completeIpc implements shell completion for the `--ipc` option of `run` and `create`. // The completion is partly composite. func completeIpc(dockerCLI completion.APIClientProvider) func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { diff --git a/cli/command/container/run.go b/cli/command/container/run.go index 78687ebe4c..f7f4ca0d1f 100644 --- a/cli/command/container/run.go +++ b/cli/command/container/run.go @@ -69,6 +69,7 @@ func NewRunCommand(dockerCli command.Cli) *cobra.Command { command.AddTrustVerificationFlags(flags, &options.untrusted, dockerCli.ContentTrustEnabled()) copts = addFlags(flags) + _ = cmd.RegisterFlagCompletionFunc("detach-keys", completeDetachKeys) addCompletions(cmd, dockerCli) return cmd