GoogleContainerTools/skaffold · error

computing the size of the Docker context: %w

Error message

computing the size of the Docker context: %w

What it means

During `skaffold diagnose`, CheckArtifacts measures the size of each Docker artifact's build context by streaming a generated tar context to io.Discard. If creating the tar context or reading it fails, the error is wrapped with this message.

Source

Thrown at pkg/skaffold/diagnose/diagnose.go:51

	timeutil "github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/util/time"
)

type Config interface {
	docker.Config

	GetPipelines() []latest.Pipeline
	Artifacts() []*latest.Artifact
}

func CheckArtifacts(ctx context.Context, cfg Config, tags tag.ImageTags, out io.Writer) error {
	for _, p := range cfg.GetPipelines() {
		for _, artifact := range p.Build.Artifacts {
			output.Default.Fprintf(out, "\n%s: %s\n", typeOfArtifact(artifact), artifact.ImageName)

			if artifact.DockerArtifact != nil {
				size, err := sizeOfDockerContext(ctx, artifact, cfg)
				if err != nil {
					return fmt.Errorf("computing the size of the Docker context: %w", err)
				}

				fmt.Fprintf(out, " - Size of the context: %vbytes\n", size)
			}

			tag, ok := tags[artifact.ImageName]
			if !ok {
				return fmt.Errorf("getting tag for image %s", artifact.ImageName)
			}

			timeDeps1, deps, err := timeToListDependencies(ctx, artifact, tag, cfg)
			if err != nil {
				return fmt.Errorf("listing artifact dependencies: %w", err)
			}
			timeDeps2, _, err := timeToListDependencies(ctx, artifact, tag, cfg)
			if err != nil {
				return fmt.Errorf("listing artifact dependencies: %w", err)
			}

View on GitHub (pinned to a1189de023)

Solutions

  1. Verify the dockerfile path in the artifact's DockerArtifact config relative to the workspace
  2. Check that all files in the workspace referenced by the Dockerfile are readable
  3. Run docker build manually in the workspace to reproduce the context error
  4. Run skaffold diagnose -vdebug to see the underlying 'creating docker context' error

Example fix

// before (skaffold.yaml)
build:
  artifacts:
    - image: app
      docker:
        dockerfile: Dockerfile.prod   # missing
// after
build:
  artifacts:
    - image: app
      docker:
        dockerfile: Dockerfile
Defensive patterns

Strategy: validation

Validate before calling

if _, err := os.Stat(filepath.Join(artifact.Workspace, artifact.DockerArtifact.DockerfilePath)); err != nil {
	return fmt.Errorf("dockerfile missing: %w", err)
}

Try / catch

if err := diagnose.CheckArtifacts(ctx, cfg, tags, out); err != nil {
	var derr interface{ Unwrap() error }
	if errors.As(err, &target) && strings.Contains(err.Error(), "size of the Docker context") {
		log.Warnf("docker context invalid: %v", err)
	}
}

Prevention

When it happens

Trigger: Running `skaffold diagnose` on a pipeline with a Docker artifact where docker.CreateDockerTarContext fails (missing Dockerfile at artifact.DockerfilePath, unreadable workspace files, context exclusion/inclusion errors) or the pipe errors mid-stream.

Common situations: Dockerfile path typo in skaffold.yaml; .dockerignore problems; workspace directory deleted or permission-denied; docker build context generation failing due to missing referenced files.

Related errors


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