{"record":{"id":"c5d0cb732400d033","repo":"redis/node-redis","slug":"docker-run-error-stderr","errorCode":null,"errorMessage":"docker run error - ${stderr}","messagePattern":"docker run error - (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/test-utils/lib/dockers.ts","lineNumber":139,"sourceCode":"\n  dockerArgs.push(\n    '-d',\n    '--network', 'host',\n    `${options.image}:${options.version}`\n  );\n\n  if (serverArguments.length > 0) {\n    for (let i = 0; i < serverArguments.length; i++) {\n      dockerArgs.push(serverArguments[i])\n    }\n  }\n\n  console.log(`[Docker] Spawning Redis container - Image: ${options.image}:${options.version}, Port: ${port}, Mode: ${options.mode}`);\n\n  const { stdout, stderr } = await execAsync('docker', dockerArgs);\n\n  if (!stdout) {\n    throw new Error(`docker run error - ${stderr}`);\n  }\n\n  while (await isPortAvailable(port)) {\n    await setTimeout(50);\n  }\n\n  return {\n    port,\n    dockerId: stdout.trim()\n  };\n}\nconst RUNNING_SERVERS = new Map<Array<string>, ReturnType<typeof spawnRedisServerDocker>>();\n\nexport interface ProxiedRedisServerDocker {\n  ports: number[],\n  apiPort: number,\n  dockerId: string\n}","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/redis/node-redis/blob/90fd0652bc3f2a0a1b2f79fa9096b02a86b0ac58/packages/test-utils/lib/dockers.ts#L121-L157","documentation":"spawnRedisServerDocker runs `docker run -d ...` via execFile. With -d, Docker prints the new container ID to stdout; if stdout is empty the code treats the run as failed and throws, including stderr. This guards against Docker refusing to start the container (daemon down, image missing, name/port conflict).","triggerScenarios":"Docker daemon not running; the configured image:version tag not present and not pullable; a port conflict on the host (the suite uses --network host); Docker Desktop not started.","commonSituations":"New developer machine without Docker installed/started; CI runner where docker pull of the test image failed silently earlier; image tag bumped but never pulled; another container already bound to the chosen port.","solutions":["Confirm Docker is reachable: docker info (start Docker Desktop / dockerd if it errors)","Pull the image manually to see the real error: docker pull <image>:<version>","Read the full stderr in the thrown message — it usually names the exact Docker refusal (port conflict, image not found, etc.)"],"exampleFix":"# before — docker run produced no container id\n# stderr in the error tells you why\n\n# after — diagnose then pull\ndocker info && docker pull redislabs/client-libs-test:7.4\n# rerun the test","handlingStrategy":"validation","validationCode":"import { execFile } from 'node:child_process';\nimport { promisify } from 'node:util';\nconst exec = promisify(execFile);\nasync function assertDockerReady(imageTag: string): Promise<void> {\n  await exec('docker', ['info']);\n  try { await exec('docker', ['image', 'inspect', imageTag]); }\n  catch { await exec('docker', ['pull', imageTag]); }\n}","typeGuard":null,"tryCatchPattern":"try {\n  await spawnRedisServerDocker(opts, args);\n} catch (e) {\n  if (e instanceof Error && /docker run error/.test(e.message)) {\n  }\n  throw e;\n}","preventionTips":["Add a preflight check (docker info + image inspect) at the top of the test suite","Surface stderr in CI logs unconditionally so docker run failures are diagnosable","Pin a known-good image tag in CI rather than relying on latest"],"tags":["docker","test-utils","container","infrastructure"],"backgroundTag":null,"analyzedSha":"90fd0652bc3f2a0a1b2f79fa9096b02a86b0ac58","analyzedAt":"2026-08-11T15:37:21.243Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}