{"record":{"id":"64a1449c3b974e66","repo":"alibaba/spring-ai-alibaba","slug":"error-executing-code-in-docker-container-e-getme","errorCode":null,"errorMessage":"Error executing code in Docker container: {e.getMessage()}","messagePattern":"Error executing code in Docker container: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"spring-boot-starters/spring-ai-alibaba-starter-builtin-nodes/src/main/java/com/alibaba/cloud/ai/graph/node/code/DockerCodeExecutor.java","lineNumber":183,"sourceCode":"\t\t\t\t}\n\t\t\t\tfinally {\n\t\t\t\t\t// Clean up container\n\t\t\t\t\tdockerClient.removeContainerCmd(container.getId()).withForce(true).exec();\n\t\t\t\t\t// Delete temporary file\n\t\t\t\t\tFileUtils.deleteFile(codeExecutionConfig.getWorkDir(), filename);\n\n\t\t\t\t\t// Delete JAR files if language is Java\n\t\t\t\t\tif (\"java\".equals(language)) {\n\t\t\t\t\t\tFileUtils.deleteResourceJarFromWorkDir(hostWorkDir);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn new CodeExecutionResult(0, allLogs.toString());\n\t\t}\n\t\tcatch (Exception e) {\n\t\t\tlogger.error(\"Error executing code in Docker container\", e);\n\t\t\tthrow new RuntimeException(\"Error executing code in Docker container: \" + e.getMessage(), e);\n\t\t}\n\t}\n\n\t@Override\n\tpublic void restart() {\n\n\t}\n\n\tprivate static class LogContainerResultCallback extends ResultCallbackTemplate<LogContainerResultCallback, Frame> {\n\n\t\tprivate final StringBuilder log = new StringBuilder();\n\n\t\t@Override\n\t\tpublic void onNext(Frame frame) {\n\t\t\tlog.append(new String(frame.getPayload()));\n\t\t}\n\n\t\t@Override","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-boot-starters/spring-ai-alibaba-starter-builtin-nodes/src/main/java/com/alibaba/cloud/ai/graph/node/code/DockerCodeExecutor.java#L165-L201","documentation":"DockerCodeExecutor.executeCodeBlocks wraps any exception raised while running code blocks inside a Docker container into a RuntimeException, preserving the original cause. This is a catch-all around Docker client calls, file mounts, and command execution, so the message text is generic and the real reason is always in the cause chain.","triggerScenarios":"Calling executeCodeBlocks (directly or via a CodeExecutionNode) when: the Docker daemon is not running or unreachable, the Docker image cannot be pulled, the bind mount / work directory cannot be created, or the container command exits abnormally and the client throws.","commonSituations":"Docker Desktop not started on the dev machine; user not in the docker group (permission denied on /var/run/docker.sock); image name typo or private registry requiring auth; running inside CI without Docker-in-Docker; out-of-disk causing mount failures.","solutions":["Read the wrapped cause (e.getCause()) in logs — logger.error already prints it — and fix the underlying Docker issue (start daemon, fix image, fix permissions).","Verify Docker is reachable: run 'docker ps' with the same user that runs the JVM.","Confirm the configured image exists locally or is pullable ('docker pull <image>').","If Docker is unavailable, switch to LocalCommandlineCodeExecutor as the executor implementation."],"exampleFix":"// before\ncodeExecutor.executeCodeBlocks(blocks, config); // RuntimeException with generic message\n// after\ntry {\n    codeExecutor.executeCodeBlocks(blocks, config);\n} catch (RuntimeException e) {\n    Throwable root = e.getCause();\n    log.error(\"Docker execution failed: {}\", root == null ? e : root.getMessage());\n    throw e;\n}","handlingStrategy":"try-catch","validationCode":"Process p = new ProcessBuilder(\"docker\", \"info\").start();\nif (p.waitFor(10, TimeUnit.SECONDS) && p.exitValue() != 0) {\n    throw new IllegalStateException(\"Docker daemon unreachable\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    result = dockerExecutor.executeCodeBlocks(blocks, config);\n} catch (RuntimeException e) {\n    Throwable cause = e.getCause();\n    log.error(\"Docker code execution failed: {}\", cause == null ? e.getMessage() : cause.getMessage(), cause);\n    throw new IllegalStateException(\"Code execution unavailable: \" + (cause == null ? \"unknown\" : cause.getMessage()), e);\n}","preventionTips":["Health-check the Docker daemon at application startup","Run 'docker ps' under the same OS user as the JVM to catch permission issues","Pre-pull the configured image and pin a version tag","Provide a local executor fallback when Docker is unavailable"],"tags":["docker","code-execution","runtime-exception","container"],"backgroundTag":"http-request-failed","analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}