GoogleContainerTools/skaffold · error

reading dockerfile: %w

Error message

reading dockerfile: %w

What it means

Fires in evalBuildArgs when the Dockerfile (after path normalization) cannot be opened for reading — most commonly the file does not exist at the resolved path, or permissions deny it. Skaffold reads it to filter build args actually referenced by the Dockerfile.

Source

Thrown at pkg/skaffold/docker/build_args.go:74

		defaults = nonDebugModeArgs
	}
	result := map[string]*string{
		"SKAFFOLD_RUN_MODE": util.Ptr(string(mode)),
	}
	for k, v := range defaults {
		result[k] = &v
	}

	for k, v := range extra {
		result[k] = v
	}
	absDockerfilePath, err := NormalizeDockerfilePath(workspace, dockerfilePath)
	if err != nil {
		return nil, fmt.Errorf("normalizing dockerfile path: %w", err)
	}
	f, err := os.Open(absDockerfilePath)
	if err != nil {
		return nil, fmt.Errorf("reading dockerfile: %w", err)
	}
	defer f.Close()
	result, err = filterUnusedBuildArgs(f, result)
	if err != nil {
		return nil, fmt.Errorf("removing unused default args: %w", err)
	}
	for k, v := range args {
		result[k] = v
	}
	result, err = util.EvaluateEnvTemplateMapWithEnv(result, env)
	if err != nil {
		return nil, fmt.Errorf("unable to expand build args: %w", err)
	}
	return result, nil
}

// ArtifactResolver provides an interface to resolve built artifact tags by image name.
type ArtifactResolver interface {

View on GitHub (pinned to a1189de023)

Solutions

  1. Confirm the Dockerfile exists at the resolved path (ls the path)
  2. Fix file permissions so the build user can read it
  3. Point docker.dockerfile at the correct file, not a directory
  4. Re-check out / restore the workspace if the file is missing

Example fix

// before (CI)
- run: rm -rf deploy/* && skaffold build
// after
- run: skaffold build   # don't delete files referenced by docker.dockerfile
Defensive patterns

Strategy: validation

Validate before calling

abs, err := docker.NormalizeDockerfilePath(workspace, dockerfilePath)
if err != nil { return err }
f, err := os.Open(abs)
if err != nil { return fmt.Errorf("dockerfile unreadable: %w", err) }
f.Close()

Try / catch

args, err := evalBuildArgs(workspace, df, args, env)
if err != nil && strings.Contains(err.Error(), "reading dockerfile") {
  return fmt.Errorf("cannot open Dockerfile %s; check existence and permissions: %w", df, err)
}

Prevention

When it happens

Trigger: evalBuildArgs calls os.Open(absDockerfilePath) and the file does not exist, is unreadable by the current user, or is a directory.

Common situations: Dockerfile deleted/renamed after config was written; restricted permissions in CI checkout; path pointing at a directory; race where a cleanup step removed the file before build.

Related errors


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