{"record":{"id":"8b0ad9bff6a2acf8","repo":"cross-rs/cross","slug":"container-container-id-was-running","errorCode":null,"errorMessage":"container {container_id} was running.","messagePattern":"container (.+?) was running\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/docker/remote.rs","lineNumber":804,"sourceCode":"        let existing = DockerVolume::existing(engine, toolchain_dirs.toolchain(), msg_info)?;\n        if existing.iter().any(|v| v == &toolchain_id) {\n            VolumeId::Keep(toolchain_id)\n        } else {\n            let partial = format!(\"{VOLUME_PREFIX}{}\", toolchain_dirs.toolchain());\n            if existing.iter().any(|v| v.starts_with(&partial)) {\n                msg_info.warn(format_args!(\n                    \"a persistent volume does not exists for `{0}`, but there is a volume for a different version.\\n > Create a new volume with `cross-util volumes create --toolchain {0}`\",\n                    toolchain_dirs.toolchain()\n                ))?;\n            }\n            VolumeId::Discard\n        }\n    };\n\n    let container = DockerContainer::new(engine, &container_id);\n    let state = container.state(msg_info)?;\n    if !state.is_stopped() {\n        msg_info.warn(format_args!(\"container {container_id} was running.\"))?;\n        container.stop_default(msg_info)?;\n    }\n    if state.exists() {\n        msg_info.warn(format_args!(\"container {container_id} was exited.\"))?;\n        container.remove(msg_info)?;\n    }\n\n    // 2. create our volume to copy all our data over to\n    // we actually use an anonymous volume, so it's auto-cleaned up,\n    // if we're using a discarded volume.\n\n    // 3. create our start container command here\n    let mut docker = engine.subcommand(\"run\");\n    docker.add_userns();\n    options\n        .image\n        .platform\n        .specify_platform(&options.engine, &mut docker);","sourceCodeStart":786,"sourceCodeEnd":822,"githubUrl":"https://github.com/cross-rs/cross/blob/8c1a8aa4b661711f4b7b6ac07c2e8929ce2f7d27/src/docker/remote.rs#L786-L822","documentation":"At the start of a remote run, cross reuses or cleans up a leftover container from a previous run. If the container with the expected ID is still running, it warns, stops it with the default timeout, and continues cleanup (removing it if it exists).","triggerScenarios":"run() finds a previous remote-build container (from a crashed/interrupted run) whose state is not stopped, so container.state(msg_info)? returns running and the warn branch fires.","commonSituations":"A previous cross remote build was killed (Ctrl-C, CI timeout, machine reboot) leaving the container running; concurrent cross runs colliding on the same container ID.","solutions":["Nothing required — cross stops and cleans the container automatically; investigate only if this repeats.","Avoid killing cross mid-build; use `crossutil`/docker CLI to clean leftover containers (`docker rm -f <container_id>`).","Ensure no two cross remote runs execute concurrently in the same Docker context."],"exampleFix":"# before: leftover container from interrupted run\n docker ps # shows cross container running\n\n# after: clean up manually if needed\ndocker rm -f <container_id>\ncross build --remote --target aarch64-unknown-linux-gnu","handlingStrategy":"fallback","validationCode":"# Detect a leftover running container before invoking cross\nid=$(docker ps -q --filter name=cross-)\n[ -n \"$id\" ] && docker rm -f \"$id\"","typeGuard":null,"tryCatchPattern":"// Warning is auto-handled; retry only if cleanup itself failed\nif let Err(e) = run() {\n    if e.to_string().contains(\"was running\") { std::thread::sleep(STOP_GRACE); retry(); } else { return Err(e); }\n}","preventionTips":["Let cross finish or use its own cancellation path instead of SIGKILL","Avoid concurrent cross remote runs in one Docker context","Prune leftover containers after CI cancellations"],"tags":["docker","remote","container","cleanup"],"backgroundTag":"invalid-state-transition","analyzedSha":"8c1a8aa4b661711f4b7b6ac07c2e8929ce2f7d27","analyzedAt":"2026-09-13T15:10:43.988Z","contentChangedAt":"2026-09-13T15:10:43.988Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}