docker/cli · error
conflicting options: cannot specify both --timeout and --tim
Error message
conflicting options: cannot specify both --timeout and --time
What it means
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.
Source
Thrown at cli/command/container/restart.go:33
type restartOptions struct {
signal string
timeout int
timeoutChanged bool
containers []string
}
// newRestartCommand creates a new cobra.Command for "docker container restart".
func newRestartCommand(dockerCLI command.Cli) *cobra.Command {
var opts restartOptions
cmd := &cobra.Command{
Use: "restart [OPTIONS] CONTAINER [CONTAINER...]",
Short: "Restart one or more containers",
Args: cli.RequiresMinArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
if cmd.Flags().Changed("time") && cmd.Flags().Changed("timeout") {
return errors.New("conflicting options: cannot specify both --timeout and --time")
}
opts.containers = args
opts.timeoutChanged = cmd.Flags().Changed("timeout") || cmd.Flags().Changed("time")
return runRestart(cmd.Context(), dockerCLI, &opts)
},
Annotations: map[string]string{
"aliases": "docker container restart, docker restart",
},
ValidArgsFunction: completion.ContainerNames(dockerCLI, true),
DisableFlagsInUseLine: true,
}
flags := cmd.Flags()
flags.StringVarP(&opts.signal, "signal", "s", "", "Signal to send to the container")
flags.IntVarP(&opts.timeout, "timeout", "t", 0, "Seconds to wait before killing the container")
// The --time option is deprecated, but kept for backward compatibility.
flags.IntVar(&opts.timeout, "time", 0, "Seconds to wait before killing the container (deprecated: use --timeout)")View on GitHub (pinned to e9452d6e78)
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
Example fix
# before docker restart --time 10 --timeout 10 web # after docker restart --timeout 10 web
When it happens
Trigger: `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.
Common situations: 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`.
Related errors
- conflicting options: cannot specify both --attach and --deta
- filtering is not supported when specifying a list of contain
- conflicting options: cannot specify both --timeout and --tim
- conflicting options: --no-pause and --pause cannot be used t
- conflicting options: cannot specify both --network-alias and
AI-assisted analysis of docker/cli@e9452d6e78 (2026-08-01).
Data as JSON: /data/errors/888ea23961a6c305.json.
Report an issue: GitHub.