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

  1. Remove the extra positional arguments; check `--help` to confirm the command takes none.
  2. If you meant to pass a value, attach it to the correct flag (e.g. `--format ...`).
  3. 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

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


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)