docker/cli · error
%[1]s: '%[2]s' accepts no arguments Usage: %[3]s Run…
Error message
%[1]s: '%[2]s' accepts no arguments Usage: %[3]s Run '%[2]s --help' for more information
What it means
Returned by cli.NoArgs (required.go:25) when the command received positional arguments AND it has no subcommands. This means the command genuinely accepts zero positional args (e.g. a status/info command) and the user supplied extras. The message includes binary name, command path, and usage.
Solutions
- Remove the extra positional arguments; check `--help` to confirm the command takes none.
- If you meant to pass a value, attach it to the correct flag (e.g. `--format ...`).
- Audit wrapper scripts that append `$@` unconditionally.
Example fix
// before: stray positional docker version myhost // after: no positional args docker version
Defensive patterns
Strategy: validation
Validate before calling
// Reject extra positionals before invoking a NoArgs command
if len(args) > 0 {
return fmt.Errorf("%s takes no positional arguments", cmdPath)
} Prevention
- Check a command's --help to confirm it is flag-only.
- Quote flag values so they are not mistaken for positionals.
- Avoid blind `$@` forwarding in wrappers.
When it happens
Trigger: A cobra command with Args: cli.NoArgs and no child commands invoked with one or more positional arguments, e.g. `docker version extra` where version takes none.
Common situations: Passing a flag value without the flag (so it becomes positional), a script appending unexpected arguments, or misunderstanding that a command is purely flag-driven.
Related errors
- %[1]s: unknown command: %[2]s %[3]s Usage: %[4]s Run…
- %[1]s: '%[2]s' requires at least %[3]d %[4]s Usage: …
- %[1]s: '%[2]s' requires at most %[3]d %[4]s Usage: …
- %[1]s: '%[2]s' requires at least %[3]d and at most %[4]d…
- %[1]s: '%[2]s' requires %[3]d %[4]s Usage: %[5]s Run…
AI-assisted analysis of docker/cli@4f84911bfe (2026-08-07).
Data as JSON: /api/errors/d467c6e74696a7ac.
Report an issue: GitHub.
Appendix: source
Thrown at cli/required.go:25
)
// NoArgs validates args and returns an error if there are any args
func NoArgs(cmd *cobra.Command, args []string) error {
if len(args) == 0 {
return nil
}
if cmd.HasSubCommands() {
return fmt.Errorf(
"%[1]s: unknown command: %[2]s %[3]s\n\nUsage: %[4]s\n\nRun '%[2]s --help' for more information",
binName(cmd),
cmd.CommandPath(),
args[0],
cmd.UseLine(),
)
}
return fmt.Errorf(
"%[1]s: '%[2]s' accepts no arguments\n\nUsage: %[3]s\n\nRun '%[2]s --help' for more information",
binName(cmd),
cmd.CommandPath(),
cmd.UseLine(),
)
}
// RequiresMinArgs returns an error if there is not at least min args
func RequiresMinArgs(minArgs int) cobra.PositionalArgs {
return func(cmd *cobra.Command, args []string) error {
if len(args) >= minArgs {
return nil
}
return fmt.Errorf(
"%[1]s: '%[2]s' requires at least %[3]d %[4]s\n\nUsage: %[5]s\n\nSee '%[2]s --help' for more information",
binName(cmd),
cmd.CommandPath(),
minArgs,View on GitHub (pinned to 4f84911bfe)