{"record":{"id":"b95627a1d62210fb","repo":"docker/cli","slug":"saving-creds-w","errorCode":null,"errorMessage":"saving creds: %w","messagePattern":"saving creds: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command/container/create.go","lineNumber":406,"sourceCode":"\t\treturn fmt.Errorf(\n\t\t\t\"invalid pull option: '%s': must be one of %q, %q or %q\",\n\t\t\tval,\n\t\t\tPullImageAlways,\n\t\t\tPullImageMissing,\n\t\t\tPullImageNever,\n\t\t)\n\t}\n}\n\n// copyDockerConfigIntoContainer takes the client configuration and copies it\n// into the container.\n//\n// The path should be an absolute path in the container, commonly\n// /root/.docker/config.json.\nfunc copyDockerConfigIntoContainer(ctx context.Context, apiClient client.APIClient, containerID string, configPath string, config *configfile.ConfigFile) error {\n\tvar configBuf bytes.Buffer\n\tif err := config.SaveToWriter(&configBuf); err != nil {\n\t\treturn fmt.Errorf(\"saving creds: %w\", err)\n\t}\n\n\t// We don't need to get super fancy with the tar creation.\n\tvar tarBuf bytes.Buffer\n\ttarWriter := tar.NewWriter(&tarBuf)\n\t_ = tarWriter.WriteHeader(&tar.Header{\n\t\tName: configPath,\n\t\tSize: int64(configBuf.Len()),\n\t\tMode: 0o600,\n\t})\n\n\tif _, err := io.Copy(tarWriter, &configBuf); err != nil {\n\t\t_ = tarWriter.Close()\n\t\treturn fmt.Errorf(\"writing config to tar file for config copy: %w\", err)\n\t}\n\n\tif err := tarWriter.Close(); err != nil {\n\t\treturn fmt.Errorf(\"closing tar for config copy failed: %w\", err)","sourceCodeStart":388,"sourceCodeEnd":424,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/command/container/create.go#L388-L424","documentation":"Thrown inside copyDockerConfigIntoContainer (create.go:406) when configfile.ConfigFile.SaveToWriter fails while serializing the local Docker config (credentials, auths) into an in-memory buffer. This is the step that prepares the config.json to be copied into the newly created container. The wrapped error (%w) carries the underlying serialization failure.","triggerScenarios":"`docker create`/`docker run` runs in a context where the user's ~/.docker/config.json exists but is structurally invalid — e.g. a corrupt credsStore field, an auth entry that cannot be re-encoded, or an incompatible credential helper entry that SaveToWriter cannot marshal.","commonSituations":"Migrating from an older Docker version that wrote a config field no longer understood, a manually edited config.json, a credsStore/credHelpers entry pointing at a helper binary that returns malformed data, or a config produced by another tool.","solutions":["Inspect ~/.docker/config.json for syntax errors: docker login again to regenerate it.","Remove or fix malformed auths/credsStore/credHelpers entries and re-login.","Back up and regenerate the config: mv ~/.docker/config.json config.json.bak && docker login.","If a credential helper is involved, verify it is installed and produces valid output."],"exampleFix":"# before (corrupt config)\ncat ~/.docker/config.json  # has a malformed \"auths\" entry\n\n# after\nmv ~/.docker/config.json ~/.docker/config.json.bak\ndocker login","handlingStrategy":"try-catch","validationCode":"// Before create, sanity-check the config parses round-trips:\nimport \"github.com/docker/cli/cli/config/configfile\"\nf, err := config.Load(os.Getenv(\"DOCKER_CONFIG\"))\nif err != nil { return err }\nvar buf bytes.Buffer\nif err := f.SaveToWriter(&buf); err != nil {\n    return fmt.Errorf(\"docker config cannot be serialized: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"// Because this is a wrapped error returned from docker create, treat it as\n// a config-integrity problem, not a transient one:\nif err := createCmd.Run(); err != nil && strings.Contains(err.Error(), \"saving creds\") {\n    // regenerate ~/.docker/config.json\n}","preventionTips":["Run `docker logout`/`docker login` to regenerate config.json after upgrades.","Never hand-edit auths/credsStore fields.","Back up config.json before editing."],"tags":["container","config","credentials","create","filesystem"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}