{"record":{"id":"9c4f13542d21fec9","repo":"docker/cli","slug":"docker-unknown-command-docker-s-run-docker","errorCode":null,"errorMessage":"docker: unknown command: docker %s\n\nRun 'docker --help' for more information","messagePattern":"docker: unknown command: docker (.+?)\n\nRun 'docker --help' for more information","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/docker/docker.go","lineNumber":152,"sourceCode":"}\n\nfunc newDockerCommand(dockerCli *command.DockerCli) *cli.TopLevelCommand {\n\tvar (\n\t\topts    *cliflags.ClientOptions\n\t\thelpCmd *cobra.Command\n\t)\n\n\tcmd := &cobra.Command{\n\t\tUse:              \"docker [OPTIONS] COMMAND [ARG...]\",\n\t\tShort:            \"A self-sufficient runtime for containers\",\n\t\tSilenceUsage:     true,\n\t\tSilenceErrors:    true,\n\t\tTraverseChildren: true,\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\tif len(args) == 0 {\n\t\t\t\treturn command.ShowHelp(dockerCli.Err())(cmd, args)\n\t\t\t}\n\t\t\treturn fmt.Errorf(\"docker: unknown command: docker %s\\n\\nRun 'docker --help' for more information\", args[0])\n\t\t},\n\t\tPersistentPreRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\treturn isSupported(cmd, dockerCli)\n\t\t},\n\t\tVersion:               fmt.Sprintf(\"%s, build %s\", version.Version, version.GitCommit),\n\t\tDisableFlagsInUseLine: true,\n\t\tCompletionOptions: cobra.CompletionOptions{\n\t\t\tDisableDefaultCmd:   false,\n\t\t\tHiddenDefaultCmd:    true,\n\t\t\tDisableDescriptions: os.Getenv(\"DOCKER_CLI_DISABLE_COMPLETION_DESCRIPTION\") != \"\",\n\t\t},\n\t}\n\n\t// Disable file-completion by default. Most commands and flags should not\n\t// complete with filenames.\n\tcmd.CompletionOptions.SetDefaultShellCompDirective(cobra.ShellCompDirectiveNoFileComp)\n\n\tcmd.SetIn(dockerCli.In())","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cmd/docker/docker.go#L134-L170","documentation":"Returned by the root cobra command's RunE in newDockerCommand() when arguments are passed but no subcommand matches (and no plugin provides it). %s is the first (unrecognized) argument. This is docker's standard 'command not found' message directing the user to `docker --help`.","triggerScenarios":"Typing a nonexistent subcommand: `docker bulid`, `docker psa`, `docker container lst`, or a plugin command whose plugin is not installed (and the plugin manager fell through to root Execute).","commonSituations":"Typos; expecting a plugin (buildx, compose, scout) that isn't installed; using a command from a newer/older docker version not present in this build.","solutions":["Check spelling against `docker --help`.","If it's a known plugin command (e.g. compose, buildx, scout), install that plugin.","Run `docker --help` to enumerate available top-level commands."],"exampleFix":"// before\n$ docker bulid .\ndocker: unknown command: docker bulid\n\nRun 'docker --help' for more information\n\n// after\n$ docker build .","handlingStrategy":"validation","validationCode":"// Validate the subcommand exists before running\nfunc commandExists(sub string) (bool, error) {\n    out, err := exec.Command(\"docker\", \"--help\").CombinedOutput()\n    if err != nil { return false, err }\n    return strings.Contains(string(out), \"  \"+sub+\" \"), nil\n}","typeGuard":null,"tryCatchPattern":"// Treat unknown command as a usage error in wrappers and surface help\nout, err := exec.CommandContext(ctx, \"docker\", sub).CombinedOutput()\nif err != nil && strings.Contains(string(out), \"unknown command\") {\n    return fmt.Errorf(\"invalid docker subcommand %q; see `docker --help`\", sub)\n}","preventionTips":["Spell-check subcommands; tab-complete in interactive shells.","Install plugins (compose, buildx, scout) before invoking their commands.","Run `docker --help` to enumerate available commands."],"tags":["docker","cli","command-not-found","usage"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}