{"record":{"id":"55d867df4ee62f3f","repo":"GoogleContainerTools/skaffold","slug":"creating-docker-context-w","errorCode":null,"errorMessage":"creating docker context: %w","messagePattern":"creating docker context: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/diagnose/diagnose.go","lineNumber":157,"sourceCode":"\treturn timeutil.Humanize(time.Since(start)), err\n}\n\nfunc timeToComputeMTimes(deps []string) (string, error) {\n\tstart := time.Now()\n\n\tif _, err := filemon.Stat(func() ([]string, error) { return deps, nil }); err != nil {\n\t\treturn \"nil\", fmt.Errorf(\"computing modTimes: %w\", err)\n\t}\n\treturn timeutil.Humanize(time.Since(start)), nil\n}\n\nfunc sizeOfDockerContext(ctx context.Context, a *latest.Artifact, cfg docker.Config) (int64, error) {\n\tbuildCtx, buildCtxWriter := io.Pipe()\n\tgo func() {\n\t\terr := docker.CreateDockerTarContext(ctx, buildCtxWriter, docker.NewBuildConfig(\n\t\t\ta.Workspace, a.ImageName, a.DockerArtifact.DockerfilePath, nil), cfg)\n\t\tif err != nil {\n\t\t\tbuildCtxWriter.CloseWithError(fmt.Errorf(\"creating docker context: %w\", err))\n\t\t\treturn\n\t\t}\n\t\tbuildCtxWriter.Close()\n\t}()\n\n\treturn io.Copy(io.Discard, buildCtx)\n}\n","sourceCodeStart":139,"sourceCodeEnd":165,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/diagnose/diagnose.go#L139-L165","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nbuildctx:\n  path: ./deploy/Dockerfile   # outside workspace\n// after\nbuild:\n  artifacts:\n    - image: myimg\n      context: ./deploy\n      docker:\n        dockerfile: Dockerfile  # inside context dir","handlingStrategy":"try-catch","validationCode":"func dockerfileExists(ws, df string) error {\n  p, err := filepath.Abs(filepath.Join(ws, df))\n  if err != nil { return err }\n  fi, err := os.Stat(p)\n  if err != nil { return err }\n  if fi.IsDir() { return fmt.Errorf(\"%s is a directory\", p) }\n  return nil\n}","typeGuard":null,"tryCatchPattern":"n, err := sizeOfDockerContext(ctx, artifact, cfg)\nif err != nil {\n  var pathErr *fs.PathError\n  if errors.As(err, &pathErr) {\n    log.Printf(\"build context file problem: %v\", pathErr)\n  }\n  return fmt.Errorf(\"cannot measure context: %w\", err)\n}","preventionTips":["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"],"tags":["docker","build-context","skaffold"],"backgroundTag":"docker-build-context-failed","analyzedSha":"a1189de023efc32d4b8e11f395acc678aa555011","analyzedAt":"2026-09-05T12:09:27.064Z","contentChangedAt":"2026-09-05T12:09:27.064Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}