hyperledger/fabric · error

container exited with %d

Error message

container exited with %d

What it means

The launched chaincode container exited with a non-registration outcome: the launcher always notifies the launch state with 'container exited with N' after Wait returns. A non-zero exit code means the chaincode process crashed or exited before registering with the peer.

Source

Thrown at core/chaincode/runtime_launcher.go:118

			// and proceed to launch chaincode
			ccinfo, err := r.ChaincodeClientInfo(ccid)
			if err != nil {
				startFailCh <- errors.WithMessage(err, "could not get connection info")
				return
			}
			if ccinfo == nil {
				startFailCh <- errors.New("could not get connection info")
				return
			}
			if err = r.Runtime.Start(ccid, ccinfo); err != nil {
				startFailCh <- errors.WithMessage(err, "error starting container")
				return
			}
			exitCode, err := r.Runtime.Wait(ccid)
			if err != nil {
				launchState.Notify(errors.Wrap(err, "failed to wait on container exit"))
			}
			launchState.Notify(errors.Errorf("container exited with %d", exitCode))
		}()
	}

	var err error
	select {
	case <-launchState.Done():
		err = errors.WithMessage(launchState.Err(), "chaincode registration failed")
	case err = <-startFailCh:
		launchState.Notify(err)
		r.Metrics.LaunchFailures.With("chaincode", ccid).Add(1)
	case <-timeoutCh:
		err = errors.Errorf("timeout expired while starting chaincode %s for transaction", ccid)
		launchState.Notify(err)
		r.Metrics.LaunchTimeouts.With("chaincode", ccid).Add(1)
	}

	success := true
	if err != nil && !alreadyStarted {

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Read the chaincode container logs (docker logs <ccid>) for the crash reason
  2. Fix chaincode startup configuration (CORE_CHAINCODE_ID_NAME, TLS env vars) and redeploy
  3. Increase container memory limits / verify the binary runs in the container image
  4. Rebuild the chaincode package for the correct architecture and commit it

Example fix

// before: mismatched env
CORE_CHAINCODE_ID_NAME=wrongcc:1.0
// after
CORE_CHAINCODE_ID_NAME=mycc:1.0
Defensive patterns

Strategy: try-catch

Validate before calling

// before invoking, sanity-check chaincode env config
if os.Getenv("CORE_CHAINCODE_ID_NAME") != "mycc:1.0" { return errors.New("chaincode id mismatch") }

Try / catch

err := launcher.Launch(ccid)
var exitErr interface{ ExitCode() int }
if errors.As(err, &exitErr) && exitErr.ExitCode() != 0 {
    // fetch docker logs for ccid, fix chaincode, redeploy
}

Prevention

When it happens

Trigger: Runtime.Wait returns a nonzero exit code for the chaincode container — the chaincode binary terminated on startup (bad flags, unhandled panic, OOM kill, missing env vars).

Common situations: Chaincode crashes due to bad CORE_CHAINCODE_ID_NAME/address config; OOM-killed container; chaincode binary incompatible with the base image; unsupported platform (e.g., ARM without a matching binary).

Related errors


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