{"record":{"id":"a21d76814476f729","repo":"docker/cli","slug":"conflicting-options-cannot-specify-both-timeout-a21d76","errorCode":null,"errorMessage":"conflicting options: cannot specify both --timeout and --time","messagePattern":"conflicting options: cannot specify both --timeout and --time","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command/container/stop.go","lineNumber":33,"sourceCode":"type stopOptions struct {\n\tsignal         string\n\ttimeout        int\n\ttimeoutChanged bool\n\n\tcontainers []string\n}\n\n// newStopCommand creates a new cobra.Command for \"docker container stop\".\nfunc newStopCommand(dockerCLI command.Cli) *cobra.Command {\n\tvar opts stopOptions\n\n\tcmd := &cobra.Command{\n\t\tUse:   \"stop [OPTIONS] CONTAINER [CONTAINER...]\",\n\t\tShort: \"Stop one or more running containers\",\n\t\tArgs:  cli.RequiresMinArgs(1),\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\tif cmd.Flags().Changed(\"time\") && cmd.Flags().Changed(\"timeout\") {\n\t\t\t\treturn errors.New(\"conflicting options: cannot specify both --timeout and --time\")\n\t\t\t}\n\t\t\topts.containers = args\n\t\t\topts.timeoutChanged = cmd.Flags().Changed(\"timeout\") || cmd.Flags().Changed(\"time\")\n\t\t\treturn runStop(cmd.Context(), dockerCLI, &opts)\n\t\t},\n\t\tAnnotations: map[string]string{\n\t\t\t\"aliases\": \"docker container stop, docker stop\",\n\t\t},\n\t\tValidArgsFunction:     completion.ContainerNames(dockerCLI, false),\n\t\tDisableFlagsInUseLine: true,\n\t}\n\n\tflags := cmd.Flags()\n\tflags.StringVarP(&opts.signal, \"signal\", \"s\", \"\", \"Signal to send to the container\")\n\tflags.IntVarP(&opts.timeout, \"timeout\", \"t\", 0, \"Seconds to wait before killing the container\")\n\n\t// The --time option is deprecated, but kept for backward compatibility.\n\tflags.IntVar(&opts.timeout, \"time\", 0, \"Seconds to wait before killing the container (deprecated: use --timeout)\")","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/command/container/stop.go#L15-L51","documentation":"Returned by the stop command when both --timeout and the deprecated --time are provided. Identical guard to restart: both flags alias the same timeout field, so setting both is ambiguous and rejected at stop.go:32-33. --time exists only for backward compatibility and is marked deprecated.","triggerScenarios":"`docker stop --time 10 --timeout 20 ctr`. Both flags Changed triggers the error.","commonSituations":"Legacy scripts with --time being migrated to --timeout with both left in. Wrapper/alias tooling appending flags. Copy-paste from mixed references.","solutions":["Use only --timeout: `docker stop --timeout 10 ctr`.","Remove the deprecated --time from automation.","Normalize flags to --timeout in your command builder before invoking docker."],"exampleFix":"// before\ndocker stop --time 10 --timeout 20 ctr\n\n// after\ndocker stop --timeout 10 ctr","handlingStrategy":"validation","validationCode":"func normalizeStopTimeout(hasTime, hasTimeout bool) error {\n    if hasTime && hasTimeout {\n        return errors.New(\"conflicting options: cannot specify both --timeout and --time\")\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Standardize on --timeout; remove --time everywhere.","Translate --time to --timeout once in wrapper tooling.","Lint against simultaneous --time and --timeout usage."],"tags":["cli-options","conflicting-flags","deprecated","container","stop"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}