slimtoolkit/slim · error

could not find an auth config for registry - %s

Error message

could not find an auth config for registry - %s

What it means

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.

Source

Thrown at pkg/app/master/inspectors/image/image_inspector.go:154

	if showPullLog {
		fmt.Printf("pull logs ====================\n")
		fmt.Println(pullLog.String())
		fmt.Printf("end of pull logs =============\n")
	}

	return nil
}

func getRegistryCredential(registryAccount, registrySecret, dockerConfigPath, registry string) (cred *docker.AuthConfiguration, err error) {
	if registryAccount != "" && registrySecret != "" {
		cred = &docker.AuthConfiguration{
			Username: registryAccount,
			Password: registrySecret,
		}
		return
	}

	missingAuthConfigErr := fmt.Errorf("could not find an auth config for registry - %s", registry)
	if dockerConfigPath != "" {
		dAuthConfigs, err := docker.NewAuthConfigurationsFromFile(dockerConfigPath)
		if err != nil {
			log.Warnf(
				"image.inspector.Pull: getDockerCredential - failed to acquire local docker config path=%s err=%s",
				dockerConfigPath,
				err.Error(),
			)
			return nil, err
		}
		r, found := dAuthConfigs.Configs[registry]
		if !found {
			return nil, missingAuthConfigErr
		}
		cred = &r
		return cred, nil
	}

View on GitHub (pinned to 81940d17fa)

Solutions

  1. Docker-login first so ~/.docker/config.json has an auths entry for the exact registry hostname: docker login <registry>.
  2. Pass credentials explicitly to slim via the registry account/secret flags/options.
  3. Point slim at the right config file if you use a non-default DOCKER_CONFIG path.
  4. For credential-helper-based registries (ECR/GCR), export static credentials into the docker config or pre-pull the image locally.

Example fix

// before: no credentials
docker-slim build myprivateregistry.example.com/app:1.0
// after
docker login myprivateregistry.example.com
docker-slim build --registry-account myuser --registry-secret mytoken myprivateregistry.example.com/app:1.0
Defensive patterns

Strategy: validation

Validate before calling

// before pulling, confirm credentials exist for this registry
import "github.com/docker/cli/cli/config"
cfg, _ := config.Load("~/.docker")
auth, err := cfg.GetAuthConfig("myprivateregistry.example.com")
if err != nil || auth.Username == "" {
    log.Fatal("docker login <registry> first")
}

Type guard

func hasAuthFor(cfg *configfile.ConfigFile, registry string) bool {
    _, ok := cfg.AuthConfigs[registry]
    return ok
}

Try / catch

if err := pull(image); err != nil && strings.Contains(err.Error(), "could not find an auth config") {
    return fmt.Errorf("run 'docker login %s' or pass --registry-account/--registry-secret: %w", registry, err)
}

Prevention

When it happens

Trigger: 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.

Common situations: 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).

Related errors


AI-assisted analysis of slimtoolkit/slim@81940d17fa (2026-08-31). Data as JSON: /api/errors/e980a14716176cc9. Report an issue: GitHub.