{"id":"949bb3fefbd5426f","repo":"docker/cli","slug":"failed-to-rename-container-w","errorCode":null,"errorMessage":"failed to rename container: %w","messagePattern":"failed to rename container: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command/container/rename.go","lineNumber":25,"sourceCode":"\t\"github.com/docker/cli/cli/command\"\n\t\"github.com/docker/cli/cli/command/completion\"\n\t\"github.com/moby/moby/client\"\n\t\"github.com/spf13/cobra\"\n)\n\n// newRenameCommand creates a new cobra.Command for \"docker container rename\".\nfunc newRenameCommand(dockerCLI command.Cli) *cobra.Command {\n\tcmd := &cobra.Command{\n\t\tUse:   \"rename CONTAINER NEW_NAME\",\n\t\tShort: \"Rename a container\",\n\t\tArgs:  cli.ExactArgs(2),\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\toldName, newName := args[0], args[1]\n\t\t\t_, err := dockerCLI.Client().ContainerRename(cmd.Context(), oldName, client.ContainerRenameOptions{\n\t\t\t\tNewName: newName,\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to rename container: %w\", err)\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\t\tAnnotations: map[string]string{\n\t\t\t\"aliases\": \"docker container rename, docker rename\",\n\t\t},\n\t\tValidArgsFunction:     completion.ContainerNames(dockerCLI, true),\n\t\tDisableFlagsInUseLine: true,\n\t}\n\treturn cmd\n}\n","sourceCodeStart":7,"sourceCodeEnd":37,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/cli/command/container/rename.go#L7-L37","documentation":"Error \"failed to rename container: %w\" thrown in docker/cli.","triggerScenarios":"Thrown at cli/command/container/rename.go:25 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"e9452d6e785f6e365712b9d71bd7517591773c86","analyzedAt":"2026-08-01T07:09:22.474Z","schemaVersion":2}