{"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/e9452d6e785f6e365712b9d71bd7517591773c86/cli/command/container/stop.go#L15-L51","documentation":"The docker CLI's `docker container stop` command accepts both --timeout (current) and --time (deprecated alias); both flags write to the same stopOptions.timeout field. The RunE handler checks cmd.Flags().Changed for each and rejects the invocation if the user set both, because there would be no deterministic winner for the shutdown grace period.","triggerScenarios":"Running `docker stop --time 5 --timeout 10 <container>` (or `docker container stop`) with both flags explicitly set on the command line, in any order and even with identical values. Setting only one of the two flags never triggers it.","commonSituations":"Shell aliases or wrapper scripts written for older Docker versions that inject --time, combined with a user adding --timeout manually; CI pipelines migrating to the new flag name while an old flag remains in a shared script fragment; copy-pasting examples from docs of different Docker versions.","solutions":["Use only --timeout (or -t): `docker stop --timeout 10 <container>`.","Remove the deprecated --time flag from scripts and aliases; it maps to the same value and is slated for removal.","Audit shell wrappers/CI templates for both flag spellings and standardize on --timeout."],"exampleFix":"# before\ndocker stop --time 5 --timeout 10 mycontainer\n# after\ndocker stop --timeout 10 mycontainer","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":["docker-cli","container","flags","deprecation"],"analyzedSha":"e9452d6e785f6e365712b9d71bd7517591773c86","analyzedAt":"2026-08-01T07:09:22.474Z","schemaVersion":2}