GoogleContainerTools/skaffold · error
retrieving labels for %q: %w
Error message
retrieving labels for %q: %w
What it means
autoSyncItem syncs buildpack-built images by reading the image's OCI labels via Docker (Labels) to derive sync rules. If querying Docker for the image's labels fails, Skaffold wraps the error with this message, including the image tag.
Source
Thrown at pkg/skaffold/sync/sync.go:192
if a.CustomArtifact.Dependencies == nil || a.CustomArtifact.Dependencies.Dockerfile == nil {
return nil, build.ErrCustomBuildNoDockerfile{}
}
return docker.SyncMap(ctx, a.Workspace, a.CustomArtifact.Dependencies.Dockerfile.Path, a.CustomArtifact.Dependencies.Dockerfile.BuildArgs, cfg)
case a.KanikoArtifact != nil:
return docker.SyncMap(ctx, a.Workspace, a.KanikoArtifact.DockerfilePath, a.KanikoArtifact.BuildArgs, cfg)
default:
return nil, build.ErrSyncMapNotSupported{}
}
}
func autoSyncItem(ctx context.Context, a *latest.Artifact, tag string, e filemon.Events, cfg docker.Config) (*Item, error) {
switch {
case a.BuildpackArtifact != nil:
labels, err := Labels(ctx, tag, cfg)
if err != nil {
return nil, fmt.Errorf("retrieving labels for %q: %w", tag, err)
}
rules, err := buildpacks.SyncRules(labels)
if err != nil {
return nil, fmt.Errorf("extracting sync rules from labels for %q: %w", tag, err)
}
return syncItem(ctx, a, tag, e, rules, cfg)
case a.JibArtifact != nil:
toCopy, toDelete, err := jib.GetSyncDiff(ctx, a.Workspace, a.JibArtifact, e)
if err != nil {
return nil, err
}
if toCopy == nil && toDelete == nil {
// do a rebuild
return nil, nil
}View on GitHub (pinned to a1189de023)
Solutions
- Run `docker image inspect <tag>` with the tag from the error to confirm the image exists locally; rebuild via `skaffold dev` if missing
- Check DOCKER_HOST / docker context to ensure the CLI talks to the same daemon used for the build
- Re-run skaffold so a fresh build re-tags the image before sync runs
Defensive patterns
Strategy: retry
Validate before calling
_, err := docker.Cli(cfg).ImageInspect(ctx, tag) // fails fast if image absent
if err != nil { return fmt.Errorf("image %s missing; rebuild first", tag) } Type guard
func imageExists(ctx context.Context, cfg docker.Config, tag string) bool {
_, err := docker.Cli(cfg).ImageInspect(ctx, tag)
return err == nil
} Try / catch
item, err := sync.NewItem(ctx, a, tag, e, cfg, builds)
if err != nil {
if strings.Contains(err.Error(), "retrieving labels") {
// rebuild and retry once
if rbErr := rebuild(ctx, a); rbErr == nil { return sync.NewItem(ctx, a, tag, e, cfg, builds) }
}
return err
} Prevention
- Avoid aggressive docker image prune while skaffold dev is running
- Keep DOCKER_HOST/docker context consistent between build and sync sessions
- Re-run skaffold build after pulling/replacing images externally
When it happens
Trigger: Syncing changes to an artifact with BuildpackArtifact set, when docker image inspect fails: the tagged image no longer exists locally, the Docker daemon is unreachable, or the tag reference is wrong/stale.
Common situations: Image was garbage-collected (prune) between build and first sync; DOCKER_HOST points at a different daemon than the one that built the image; a newer image was pushed and the old tag removed.
Related errors
- extracting sync rules from labels for %q: %w
- Sync: Auto is not supported by the build of %s
- %q running container image %q errored during run with status
- docker deployment not supported alongside cluster deployment
- INIT_DOCKER_NETWORK_CONTAINER_DOES_NOT_EXIST
AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05).
Data as JSON: /api/errors/dfc8d2b1aaa2a5f1.
Report an issue: GitHub.