GoogleContainerTools/skaffold · error

image %q context %q is not a directory

Error message

image %q context %q is not a directory

What it means

CheckWorkspaces checks that each artifact's build context is a directory. This error is returned when os.Stat succeeds but the workspace path resolves to a file, symlink-to-file, socket, etc. — anything that is not a directory. Build contexts must be directories.

Source

Thrown at pkg/skaffold/runner/build.go:160

			Tag:         tags[artifact.ImageName],
			RuntimeType: artifact.RuntimeType,
		})
	}

	return bRes
}

func CheckWorkspaces(artifacts []*latest.Artifact) error {
	for _, a := range artifacts {
		if a.Workspace != "" {
			if info, err := os.Stat(a.Workspace); err != nil {
				// err could be permission-related
				if os.IsNotExist(err) {
					return fmt.Errorf("image %q context %q does not exist", a.ImageName, a.Workspace)
				}
				return fmt.Errorf("image %q context %q: %w", a.ImageName, a.Workspace, err)
			} else if !info.IsDir() {
				return fmt.Errorf("image %q context %q is not a directory", a.ImageName, a.Workspace)
			}
		}
	}
	return nil
}

View on GitHub (pinned to a1189de023)

Solutions

  1. Change the artifact `context:` in skaffold.yaml to point to the directory containing the Dockerfile
  2. Verify with `ls -la <path>` that the target is a directory (`d` in the mode column)
  3. If you intended a single-file build input, move it into a context directory and reference that directory

Example fix

// before (skaffold.yaml)
build:
  artifacts:
    - image: app
      context: ./deploy/Dockerfile
// after
build:
  artifacts:
    - image: app
      context: ./deploy   # directory containing the Dockerfile
Defensive patterns

Strategy: validation

Validate before calling

const info = await fs.promises.stat(artifact.Workspace)
if (!info.isDirectory()) {
  throw new Error(`artifact context must be a directory, got: ${artifact.Workspace}`)
}

Prevention

When it happens

Trigger: A skaffold.yaml artifact's `context`/`workspace` points at a regular file (e.g. `context: ./Dockerfile` or `context: ./config.yaml`) instead of a directory.

Common situations: Typo in the context path so it accidentally names a file; pointing at a tarball or single-file build input; a file replacing a directory after a refactor or git operation.

Related errors


AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05). Data as JSON: /api/errors/53ec8036c93c49f0. Report an issue: GitHub.