redis/node-redis · warning · Error
docker rm error - ${stderr}
Error message
docker rm error - ${stderr} What it means
dockerRemove runs `docker rm -f <id>` and treats ANY non-empty stderr as fatal. This runs in after() hooks that clean up Redis/proxy/cluster/sentinel containers. Note that Docker sometimes writes warnings to stderr even on success, so this guard can fire on benign messages.
Source
Thrown at packages/test-utils/lib/dockers.ts:241
dockerId: stdout.trim(),
};
}
export function spawnRedisServer(dockerConfig: RedisServerDockerOptions, serverArguments: Array<string>): Promise<RedisServerDocker> {
const runningServer = RUNNING_SERVERS.get(serverArguments);
if (runningServer) {
return runningServer;
}
const dockerPromise = spawnRedisServerDocker(dockerConfig, serverArguments);
RUNNING_SERVERS.set(serverArguments, dockerPromise);
return dockerPromise;
}
async function dockerRemove(dockerId: string): Promise<void> {
const { stderr } = await execAsync('docker', ['rm', '-f', dockerId]);
if (stderr) {
throw new Error(`docker rm error - ${stderr}`);
}
}
/**
* Reads a file from a Docker container directly into memory
* @param dockerId - The Docker container ID
* @param filePath - Path to the file inside the container
* @returns Buffer containing the file contents
*/
async function readFileFromContainer(
dockerId: string,
filePath: string,
): Promise<Buffer> {
const { stdout, stderr } = await execAsync("docker", [
"exec",
dockerId,View on GitHub (pinned to 90fd0652bc)
Solutions
- Read the stderr text in the message — if it is a 'No such container' notice, the container was already gone and the error is benign
- Filter stderr for the known-benign 'No such container' substring before failing
- Run docker ps -a to see what containers remain and reconcile state
Example fix
// before — any stderr aborts removal
const { stderr } = await execAsync('docker', ['rm', '-f', dockerId]);
if (stderr) throw new Error(`docker rm error - ${stderr}`);
// after — tolerate 'No such container'
if (stderr && !/No such container/i.test(stderr)) {
throw new Error(`docker rm error - ${stderr}`);
} Defensive patterns
Strategy: try-catch
Validate before calling
import { execFile } from 'node:child_process';
import { promisify } from 'node:util';
const exec = promisify(execFile);
async function containerExists(id: string): Promise<boolean> {
try { await exec('docker', ['inspect', id]); return true; } catch { return false; }
} Try / catch
try {
await dockerRemove(dockerId);
} catch (e) {
if (e instanceof Error && /docker rm error/.test(e.message) && /No such container/.test(e.message)) {
return; // already removed, benign
}
throw e;
} Prevention
- Tolerate 'No such container' in stderr rather than failing cleanup
- Track removed ids in a Set to avoid double cleanup
- Run cleanup in after() hooks with this.timeout raised so slow removals don't time out
When it happens
Trigger: Container already removed by a prior cleanup pass (double cleanup); container ID invalid/stale; Docker daemon error during forced removal; a non-fatal warning written to stderr.
Common situations: A test crashed mid-suite and partial cleanup already ran; the after() hook and an explicit teardown both target the same container; Docker emits a deprecation/policy warning to stderr.
Related errors
- docker run error - ${stderr}
- All ports are in use
- Failed to read ${filePath} from container: ${stderr}
- TLS certificates not available after ${maxWaitMs}ms
- Invalid JSON configuration: ${error}
AI-assisted analysis of redis/node-redis@90fd0652bc (2026-08-11).
Data as JSON: /api/errors/d8284b8bfa832bf1.
Report an issue: GitHub.