{"record":{"id":"f6ab39cfae90c69e","repo":"cross-rs/cross","slug":"container-container-id-was-exited","errorCode":null,"errorMessage":"container {container_id} was exited.","messagePattern":"container (.+?) was exited\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/docker/remote.rs","lineNumber":808,"sourceCode":"            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);\n    docker.args([\"--name\", &container_id]);\n    docker.arg(\"--rm\");\n    docker.args([\"-v\", &volume.mount(mount_prefix)]);\n","sourceCodeStart":790,"sourceCodeEnd":826,"githubUrl":"https://github.com/cross-rs/cross/blob/8c1a8aa4b661711f4b7b6ac07c2e8929ce2f7d27/src/docker/remote.rs#L790-L826","documentation":"Continuing the same startup cleanup, if the leftover remote-build container exists but is stopped (exited), cross warns that it was exited and removes it before proceeding so the new run can create a fresh container with the same ID.","triggerScenarios":"run() inspects the leftover container, state.exists() is true and it is stopped (not running), so the `was exited` warning fires and the container is removed.","commonSituations":"A previous cross remote build ended abnormally leaving an exited container; a build error stopped the container but cross never cleaned it up; CI cancellations.","solutions":["Nothing required — cross removes the exited container automatically.","If it recurs often, check why prior runs exit abnormally (build errors, OOM, CI cancellation) and fix the root cause.","Manually prune with `docker container prune` if stale containers accumulate."],"exampleFix":"# before: stale exited container\n docker ps -a # shows exited cross container\n\n# after\ndocker container prune\ncross build --remote --target aarch64-unknown-linux-gnu","handlingStrategy":"fallback","validationCode":"# Detect stale exited containers before a remote run\nid=$(docker ps -aq --filter name=cross- --filter status=exited)\n[ -n \"$id\" ] && docker rm \"$id\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Investigate why previous runs exit abnormally (build errors, OOM, cancellations)","Schedule docker container prune in CI","Let cross complete its cleanup instead of hard-killing runs"],"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"}