{"record":{"id":"fcf9d28776159212","repo":"hyperledger/fabric","slug":"docker-image-inspection-failed","errorCode":null,"errorMessage":"docker image inspection failed","messagePattern":"docker image inspection failed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/container/dockercontroller/dockercontroller.go","lineNumber":165,"sourceCode":"\t}\n\n\t// This is an awkward translation, but better here in a future dead path\n\t// than elsewhere.  The old enum types are capital, but at least as implemented\n\t// lifecycle tools seem to allow type to be set lower case.\n\tccType := strings.ToUpper(metadata.Type)\n\n\t_, err = vm.Client.ImageInspect(context.Background(), imageName)\n\tif err != nil && strings.Contains(err.Error(), \"No such image\") {\n\t\tdockerfileReader, err := vm.PlatformBuilder.GenerateDockerBuild(ccType, metadata.Path, codePackage)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrap(err, \"platform builder failed\")\n\t\t}\n\t\terr = vm.buildImage(ccid, dockerfileReader)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrap(err, \"docker image build failed\")\n\t\t}\n\t} else if err != nil {\n\t\treturn nil, errors.Wrap(err, \"docker image inspection failed\")\n\t}\n\n\treturn &ContainerInstance{\n\t\tDockerVM: vm,\n\t\tCCID:     ccid,\n\t\tType:     ccType,\n\t}, nil\n}\n\n// In order to support starting chaincode containers built with Fabric v1.4 and earlier,\n// we must check for the precense of the start.sh script for Node.js chaincode before\n// attempting to call it.\nvar nodeStartScript = `\nset -e\nif [ -x /chaincode/start.sh ]; then\n\t/chaincode/start.sh --peer.address %[1]s\nelse\n\tcd /usr/local/src","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/container/dockercontroller/dockercontroller.go#L147-L183","documentation":"Thrown by DockerVM.Build when vm.Client.ImageInspect returns an error that does NOT contain 'No such image'. Build treats 'No such image' as the normal 'must build' path; any other inspect error (daemon unreachable, permission denied, malformed image name, context canceled) is wrapped here. It means the peer could not even determine whether the chaincode image exists.","triggerScenarios":"Calling Build when the Docker daemon is down or restarting; the docker socket is not accessible (permission denied); the image name produced by GetVMNameForDocker is rejected; or the inspect request is canceled/times out.","commonSituations":"Peer container without the docker socket mounted (/var/run/docker.sock missing) → 'Cannot connect to the Docker daemon'; SELinux/permission issues on the socket; DOCKER_HOST pointing to an unreachable daemon; transient daemon unavailability during node restart.","solutions":["Verify the Docker daemon is running and reachable: docker ps from inside the peer's environment; fix DOCKER_HOST or mount /var/run/docker.sock into the peer container.","Fix socket permissions (add peer user to docker group, or adjust SELinux label with :z on the volume mount).","Check the wrapped error text in the peer log for the precise daemon error and address it (DNS, TLS, timeout).","Retry the chaincode build after the daemon recovers; the inspect probe is transient-state sensitive."],"exampleFix":"// before: peer cannot reach docker\ndocker run hyperledger/fabric-peer ...  # no docker socket mounted\n// after\ndocker run -v /var/run/docker.sock:/var/run/docker.sock hyperledger/fabric-peer ...","handlingStrategy":"validation","validationCode":"cli, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())\nif err != nil {\n\treturn fmt.Errorf(\"docker client init failed: %w\", err)\n}\nif _, err := cli.Info(context.Background()); err != nil {\n\treturn fmt.Errorf(\"docker daemon not inspectable: %w\", err)\n}","typeGuard":"func isNoSuchImage(err error) bool {\n\treturn err != nil && strings.Contains(err.Error(), \"No such image\")\n}","tryCatchPattern":"inst, err := vm.Build(ccid, meta, codePackage)\nif err != nil {\n\tif strings.Contains(err.Error(), \"docker image inspection failed\") {\n\t\t// daemon connectivity/permission problem — check DOCKER_HOST,\n\t\t// socket mount, and permissions before retrying\n\t}\n\treturn err\n}","preventionTips":["Mount /var/run/docker.sock into the peer container with correct permissions.","Set DOCKER_HOST correctly when the daemon is remote; verify with docker ps from the peer.","Monitor Docker daemon health (systemd, healthchecks) to catch restarts before deploys."],"tags":["hyperledger-fabric","docker-daemon","connectivity","go"],"backgroundTag":"cannot-connect-to-docker-daemon","analyzedSha":"2736b63f8fd5932511d56fe68b7039d15977f7f6","analyzedAt":"2026-09-04T08:52:36.465Z","contentChangedAt":"2026-09-04T08:52:36.465Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}