{"record":{"id":"e980a14716176cc9","repo":"slimtoolkit/slim","slug":"could-not-find-an-auth-config-for-registry-s","errorCode":null,"errorMessage":"could not find an auth config for registry - %s","messagePattern":"could not find an auth config for registry - (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/app/master/inspectors/image/image_inspector.go","lineNumber":154,"sourceCode":"\tif showPullLog {\n\t\tfmt.Printf(\"pull logs ====================\\n\")\n\t\tfmt.Println(pullLog.String())\n\t\tfmt.Printf(\"end of pull logs =============\\n\")\n\t}\n\n\treturn nil\n}\n\nfunc getRegistryCredential(registryAccount, registrySecret, dockerConfigPath, registry string) (cred *docker.AuthConfiguration, err error) {\n\tif registryAccount != \"\" && registrySecret != \"\" {\n\t\tcred = &docker.AuthConfiguration{\n\t\t\tUsername: registryAccount,\n\t\t\tPassword: registrySecret,\n\t\t}\n\t\treturn\n\t}\n\n\tmissingAuthConfigErr := fmt.Errorf(\"could not find an auth config for registry - %s\", registry)\n\tif dockerConfigPath != \"\" {\n\t\tdAuthConfigs, err := docker.NewAuthConfigurationsFromFile(dockerConfigPath)\n\t\tif err != nil {\n\t\t\tlog.Warnf(\n\t\t\t\t\"image.inspector.Pull: getDockerCredential - failed to acquire local docker config path=%s err=%s\",\n\t\t\t\tdockerConfigPath,\n\t\t\t\terr.Error(),\n\t\t\t)\n\t\t\treturn nil, err\n\t\t}\n\t\tr, found := dAuthConfigs.Configs[registry]\n\t\tif !found {\n\t\t\treturn nil, missingAuthConfigErr\n\t\t}\n\t\tcred = &r\n\t\treturn cred, nil\n\t}\n","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/slimtoolkit/slim/blob/81940d17fa112cc678e32209214bcb2355cb3004/pkg/app/master/inspectors/image/image_inspector.go#L136-L172","documentation":"When pulling a private image, image_inspector's getRegistryCredential (called from Pull) could not resolve credentials for the given registry. docker-slim tries the provided registry account/secret, then a docker config file path, and throws this error when no auth config can be constructed. The pull cannot authenticate to the registry without it.","triggerScenarios":"Pulling an image from a private registry while no matching auth entry exists: no registryAccount/registrySecret given and no usable ~/.docker/config.json (or the path passed via the docker config option) contains credentials for that registry hostname.","commonSituations":"Private registries (ECR, GCR, Artifactory) whose credentials are stored only in credential helpers that docker-slim cannot read; running slim in CI without a mounted docker config; registry hostname spelled differently than the auth entry (e.g. missing port or https:// prefix).","solutions":["Docker-login first so ~/.docker/config.json has an auths entry for the exact registry hostname: docker login <registry>.","Pass credentials explicitly to slim via the registry account/secret flags/options.","Point slim at the right config file if you use a non-default DOCKER_CONFIG path.","For credential-helper-based registries (ECR/GCR), export static credentials into the docker config or pre-pull the image locally."],"exampleFix":"// before: no credentials\ndocker-slim build myprivateregistry.example.com/app:1.0\n// after\ndocker login myprivateregistry.example.com\ndocker-slim build --registry-account myuser --registry-secret mytoken myprivateregistry.example.com/app:1.0","handlingStrategy":"validation","validationCode":"// before pulling, confirm credentials exist for this registry\nimport \"github.com/docker/cli/cli/config\"\ncfg, _ := config.Load(\"~/.docker\")\nauth, err := cfg.GetAuthConfig(\"myprivateregistry.example.com\")\nif err != nil || auth.Username == \"\" {\n    log.Fatal(\"docker login <registry> first\")\n}","typeGuard":"func hasAuthFor(cfg *configfile.ConfigFile, registry string) bool {\n    _, ok := cfg.AuthConfigs[registry]\n    return ok\n}","tryCatchPattern":"if err := pull(image); err != nil && strings.Contains(err.Error(), \"could not find an auth config\") {\n    return fmt.Errorf(\"run 'docker login %s' or pass --registry-account/--registry-secret: %w\", registry, err)\n}","preventionTips":["Run docker login for each private registry before using slim in that shell/CI job.","In CI, mount or generate ~/.docker/config.json with static auth (avoid helper-only creds).","Use the exact registry hostname (including port) in both docker login and the image reference."],"tags":["docker","registry","authentication"],"backgroundTag":"missing-registry-credentials","analyzedSha":"81940d17fa112cc678e32209214bcb2355cb3004","analyzedAt":"2026-08-31T23:06:12.682Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}