GoogleContainerTools/skaffold · error
creating docker context: %w
Error message
creating docker context: %w
What it means
Wraps any failure from docker.CreateDockerTarContext, which builds the tar archive of the build context sent to the Docker daemon. The writer pipe is closed with this error so io.Copy surfaces it; it means the build context could not be created (bad Dockerfile path, missing files, unreadable .dockerignore patterns, or image name issues).
Source
Thrown at pkg/skaffold/diagnose/diagnose.go:157
return timeutil.Humanize(time.Since(start)), err
}
func timeToComputeMTimes(deps []string) (string, error) {
start := time.Now()
if _, err := filemon.Stat(func() ([]string, error) { return deps, nil }); err != nil {
return "nil", fmt.Errorf("computing modTimes: %w", err)
}
return timeutil.Humanize(time.Since(start)), nil
}
func sizeOfDockerContext(ctx context.Context, a *latest.Artifact, cfg docker.Config) (int64, error) {
buildCtx, buildCtxWriter := io.Pipe()
go func() {
err := docker.CreateDockerTarContext(ctx, buildCtxWriter, docker.NewBuildConfig(
a.Workspace, a.ImageName, a.DockerArtifact.DockerfilePath, nil), cfg)
if err != nil {
buildCtxWriter.CloseWithError(fmt.Errorf("creating docker context: %w", err))
return
}
buildCtxWriter.Close()
}()
return io.Copy(io.Discard, buildCtx)
}
View on GitHub (pinned to a1189de023)
Solutions
- Verify the Dockerfile path in the artifact config is relative to the workspace and the file exists
- Run with --v.Debug and check the wrapped inner error (io.Copy error side) for the real cause
- Check .dockerignore for invalid syntax that makes context creation fail
- Ensure all files in the workspace are readable by the current user
Example fix
// before
buildctx:
path: ./deploy/Dockerfile # outside workspace
// after
build:
artifacts:
- image: myimg
context: ./deploy
docker:
dockerfile: Dockerfile # inside context dir Defensive patterns
Strategy: try-catch
Validate before calling
func dockerfileExists(ws, df string) error {
p, err := filepath.Abs(filepath.Join(ws, df))
if err != nil { return err }
fi, err := os.Stat(p)
if err != nil { return err }
if fi.IsDir() { return fmt.Errorf("%s is a directory", p) }
return nil
} Try / catch
n, err := sizeOfDockerContext(ctx, artifact, cfg)
if err != nil {
var pathErr *fs.PathError
if errors.As(err, &pathErr) {
log.Printf("build context file problem: %v", pathErr)
}
return fmt.Errorf("cannot measure context: %w", err)
} Prevention
- Keep the Dockerfile inside the artifact context directory
- Lint .dockerignore syntax (no empty negation mistakes)
- Test builds locally with plain `docker build` before skaffold
- Ensure workspace files are readable in CI
When it happens
Trigger: sizeOfDockerContext called during diagnose; CreateDockerTarContext fails because the Dockerfile path is wrong, workspace files are missing/unreadable, the image name is invalid, or the .dockerignore is malformed.
Common situations: Dockerfile not present in the artifact workspace; Dockerfile outside the workspace context; symlinked or permission-denied files referenced by the context; malformed .dockerignore exclude patterns.
Related errors
- %q running container image %q errored during run with status
- docker deployment not supported alongside cluster deployment
- INIT_DOCKER_NETWORK_CONTAINER_DOES_NOT_EXIST
- executing build: %w
- executing build: %w
AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05).
Data as JSON: /api/errors/55d867df4ee62f3f.
Report an issue: GitHub.