infiniflow/ragflow · error · RuntimeError
Directory creation failed: {stderr}
Error message
Directory creation failed: {stderr} What it means
Raised in the self-managed sandbox executor after `docker exec <container> mkdir -p /workspace/<task_id>` returns a non-zero exit code. It means the Docker CLI ran but the mkdir inside the target container failed. The stderr captured from the docker exec call is embedded in the message.
Source
Thrown at agent/sandbox/executor_manager/services/execution.py:231
bundle = _build_execution_bundle(req, workdir)
code_name = str(bundle["code_name"])
runner_name = str(bundle["runner_name"])
code_path = os.path.join(workdir, code_name)
with open(code_path, "wb") as f:
f.write(bundle["code_bytes"])
runner_path = os.path.join(workdir, runner_name)
with open(runner_path, "w", encoding="utf-8") as f:
f.write(str(bundle["runner_source"]))
args_path = os.path.join(workdir, str(bundle["args_name"]))
with open(args_path, "w", encoding="utf-8") as f:
f.write(str(bundle["args_source"]))
returncode, _, stderr = await async_run_command("docker", "exec", container, "mkdir", "-p", f"/workspace/{task_id}", timeout=5)
if returncode != 0:
raise RuntimeError(f"Directory creation failed: {stderr}")
tar_proc = await asyncio.create_subprocess_exec("tar", "czf", "-", "-C", workdir, code_name, runner_name, str(bundle["args_name"]), stdout=asyncio.subprocess.PIPE)
tar_stdout, _ = await tar_proc.communicate()
docker_proc = await asyncio.create_subprocess_exec(
"docker", "exec", "-i", container, "tar", "xzf", "-", "-C", f"/workspace/{task_id}", stdin=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE
)
stdout, stderr = await docker_proc.communicate(input=tar_stdout)
if docker_proc.returncode != 0:
raise RuntimeError(stderr.decode())
start_time = time.time()
try:
arguments = req.arguments or {}
logger.info("Passed in args keys=%s size_bytes=%s", list(arguments.keys()), len(json.dumps(arguments, ensure_ascii=False).encode("utf-8")))
run_args = _build_container_run_args(language=language, task_id=task_id, container=container, runner_name=runner_name)
View on GitHub (pinned to 554fb1133a)
Solutions
- Check the stderr text in the message: 'No such container' means the container id/name is stale — recreate it before dispatching execution.
- Verify Docker connectivity from the executor host: `docker exec <container> mkdir -p /workspace/test` manually.
- Ensure the executor user has access to /var/run/docker.sock (add to docker group or grant socket permissions).
- If using a minimal image, switch to one containing coreutils (mkdir, tar) or add them to the image.
Example fix
# before
returncode, _, stderr = await async_run_command("docker", "exec", container, "mkdir", "-p", f"/workspace/{task_id}", timeout=5)
if returncode != 0:
raise RuntimeError(f"Directory creation failed: {stderr}")
# after: verify the container is alive first and include actionable context
returncode, _, stderr = await async_run_command("docker", "inspect", "-f", "{{.State.Running}}", container, timeout=5)
if returncode != 0 or stderr.strip() != "true":
raise RuntimeError(f"Sandbox container {container} is not running; recreate it before executing") Defensive patterns
Strategy: validation
Validate before calling
# Verify the container exists and is running before staging code
returncode, out, err = await async_run_command(
"docker", "inspect", "-f", "{{.State.Running}}", container, timeout=5
)
if returncode != 0 or out.strip() != "true":
raise RuntimeError(f"Container {container} not running; recreate before execution") Try / catch
try:
await run_execution(...)
except RuntimeError as e:
if "Directory creation failed" in str(e):
# container/environment problem: recreate sandbox container and retry once
await recreate_container(container)
else:
raise Prevention
- Health-check the sandbox container (docker inspect) before every execution dispatch.
- Run the executor on a host with Docker installed and socket access for its user.
- Use an image containing coreutils (mkdir, tar).
- Monitor container lifetime so cleanup jobs cannot reap live sandboxes.
When it happens
Trigger: Calling the executor's run path (which stages code into a container) when: the named container does not exist or has exited (`Error: No such container`), the Docker daemon is unreachable from the executor process, the image lacks /bin/mkdir or a usable shell, or the workspace parent is read-only inside the container.
Common situations: Sandbox container was reaped by a cleanup job between creation and code staging; executor runs on a host without Docker installed or without permission to the Docker socket; container name mismatch after restart; minimal distroless image without coreutils.
Related errors
- {stderr.decode()}
- Command timed out
- Failed to initialize sandbox provider: {provider_type}. Conf
- No sandbox provider configured. Please configure sandbox set
- Invalid base64 encoding: {str(e)}
AI-assisted analysis of infiniflow/ragflow@554fb1133a (2026-08-15).
Data as JSON: /api/errors/1996815227d133ef.
Report an issue: GitHub.