hyperledger/fabric · error

Error downloading output: %s

Error message

Error downloading output: %s

What it means

After a successful build, DockerBuild copies the artifact tarball from /chaincode/output/. inside the container via CopyFromContainer. If that docker API call fails, this error wraps the docker client error. It means the build itself succeeded but the results could not be retrieved, and note that io.Copy into opts.OutputStream afterwards ignores errors, so this error only covers the copy-from call itself.

Source

Thrown at core/chaincode/platforms/util/utils.go:168

		return fmt.Errorf("Error waiting for container to complete: %s", err)
	}

	// Wait for stream copying to complete before accessing stdout.
	defer cw.Close()
	buff, _ := io.ReadAll(cw.Reader)
	if res.StatusCode > 0 {
		logger.Errorf("Docker build failed using options: %s", opts)
		return fmt.Errorf("Error returned from build: %d \"%s\"", res.StatusCode, string(buff))
	}

	logger.Debugf("Build output is %s", string(buff))

	// -----------------------------------------------------------------------------------
	// Finally, download the result
	// -----------------------------------------------------------------------------------
	resCont, err := client.CopyFromContainer(context.Background(), container.ID, dcli.CopyFromContainerOptions{SourcePath: "/chaincode/output/."})
	if err != nil {
		return fmt.Errorf("Error downloading output: %s", err)
	}
	defer resCont.Content.Close()
	io.Copy(opts.OutputStream, resCont.Content)

	return nil
}

// ParamsImage returns the go, os version and architecture of the ccenv image
func ParamsImage(client dcli.APIClient) (string, string, string, error) {
	image := GetDockerImageFromConfig("chaincode.builder")
	if image == "" {
		return "", "", "", fmt.Errorf("No image provided and \"chaincode.builder\" default does not exist")
	}

	// -----------------------------------------------------------------------------------
	// Ensure the image exists locally, or pull it from a registry if it doesn't
	// -----------------------------------------------------------------------------------
	_, err := client.ImageInspect(context.Background(), image)

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Ensure the builder image creates and populates /chaincode/output — the standard hyperledger/fabric-ccenv image does; custom builders must replicate this layout
  2. Retry the build; if a concurrent removal races the copy, eliminate external 'docker rm' cleanup of peer-managed containers
  3. Check docker daemon health and disk space (a full /var/lib/docker can break archive operations)
  4. Confirm the chaincode package is valid so the build actually wrote artifacts, then re-run package/install
Defensive patterns

Strategy: retry

Validate before calling

// Confirm the builder image produces /chaincode/output before relying on it
// run a smoke build once and inspect the archive layout:
//   docker run --rm <builder> /bin/sh -c 'mkdir -p /chaincode/output'
if err := util.DockerBuild(probeOpts, client); err != nil {
    return fmt.Errorf("builder smoke test failed: %w", err)
}

Try / catch

if err := util.DockerBuild(opts, client); err != nil {
    if strings.Contains(err.Error(), "Error downloading output") && attempt < maxAttempts {
        // transient daemon failure: retry the whole build
        return retryBuild(opts, client, attempt+1)
    }
    return err
}

Prevention

When it happens

Trigger: client.CopyFromContainer for path /chaincode/output/. returns an error: the builder image/container lacks a /chaincode/output directory (custom image without the expected layout), the container already exited and was removed, or the docker daemon rejects the archive request.

Common situations: Using a custom 'chaincode.builder' image that does not create /chaincode/output (the standard ccenv does); another component removing the ephemeral container before the copy (racing with the deferred ContainerRemove); daemon errors mid-build; failed external build (chaincode.externalBuilders misconfig) paths where the expected layout differs.

Related errors


AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04). Data as JSON: /api/errors/1c598bcb7aa63772. Report an issue: GitHub.