{"id":"888ea23961a6c305","repo":"docker/cli","slug":"conflicting-options-cannot-specify-both-timeout","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/restart.go","lineNumber":33,"sourceCode":"type restartOptions struct {\n\tsignal         string\n\ttimeout        int\n\ttimeoutChanged bool\n\n\tcontainers []string\n}\n\n// newRestartCommand creates a new cobra.Command for \"docker container restart\".\nfunc newRestartCommand(dockerCLI command.Cli) *cobra.Command {\n\tvar opts restartOptions\n\n\tcmd := &cobra.Command{\n\t\tUse:   \"restart [OPTIONS] CONTAINER [CONTAINER...]\",\n\t\tShort: \"Restart one or more 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 runRestart(cmd.Context(), dockerCLI, &opts)\n\t\t},\n\t\tAnnotations: map[string]string{\n\t\t\t\"aliases\": \"docker container restart, docker restart\",\n\t\t},\n\t\tValidArgsFunction:     completion.ContainerNames(dockerCLI, true),\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/restart.go#L15-L51","documentation":"Raised in newRestartCommand's RunE for `docker restart` when both the modern --timeout/-t flag and the deprecated legacy --time flag were explicitly set. Both flags configure the same value (seconds to wait before killing the container), so the CLI refuses ambiguous input instead of silently picking one.","triggerScenarios":"`docker restart --timeout 10 --time 20 <container>` or `docker container restart -t 5 --time 5 ...` — any invocation where cobra reports both flags as Changed. Setting just one of them is fine.","commonSituations":"Scripts written for older Docker versions using --time combined with newer wrappers/aliases that append --timeout; migration from the deprecated --time flag where both got left in the command line; the same guard exists on `docker stop`.","solutions":["Remove one of the flags; prefer the current --timeout/-t: docker restart --timeout 10 mycontainer","Update legacy scripts to replace the deprecated --time with --timeout","If a wrapper injects one flag automatically, drop the duplicate from your own arguments"],"exampleFix":"# before\ndocker restart --time 10 --timeout 10 web\n# after\ndocker restart --timeout 10 web","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":["docker-cli","container","restart","conflicting-flags","deprecation"],"analyzedSha":"e9452d6e785f6e365712b9d71bd7517591773c86","analyzedAt":"2026-08-01T07:09:22.474Z","schemaVersion":2}