cross-rs/cross · warning
unknown container state: got
Error message
unknown container state: got {state} What it means
`ContainerState::new` maps Docker's Status field strings onto the ContainerState enum. Recognized values are running, paused, restarting, dead, exited, and empty (does not exist). Any other string is rejected, guarding against unexpected daemon output or API changes.
Solutions
- Check the exact status string produced by the container engine (`docker inspect -f '{{.State.Status}}' <id>`).
- Trim whitespace and lowercase the status before passing it in.
- Confirm the engine is Docker-compatible and its status vocabulary matches what's expected; update the parser mapping if a new state was introduced.
Example fix
// before
let state = ContainerState::new("Created")? // fails: unknown
// after
let state = ContainerState::new("created")? // if supported upstream, or use documented states like "running" Defensive patterns
Strategy: validation
Validate before calling
const STATES: [&str; 6] = ["running", "paused", "restarting", "dead", "exited", ""];
let s = status.trim().to_lowercase();
if !STATES.contains(&s.as_str()) {
eprintln!("warning: unrecognized container status {status:?}");
} Type guard
fn is_known_state(s: &str) -> bool {
matches!(s.trim().to_lowercase().as_str(), "running" | "paused" | "restarting" | "dead" | "exited" | "")
} Prevention
- Take status strings directly from a stable source like `docker inspect -f '{{.State.Status}}'`.
- Trim and lowercase engine output before constructing ContainerState.
- Log unrecognized statuses instead of silently ignoring them so parser drift is caught.
When it happens
Trigger: Calling `ContainerState::new` with a status string outside Docker's documented set — e.g. a truncated/renamed status from `docker inspect`/`docker ps --format`, custom formatting, or a newer Docker daemon emitting a new state.
Common situations: Parsing `docker ps` output with a custom --format that yields unexpected text, whitespace/case mismatches ("Running" vs "running"), or a Docker/Podman version difference in status strings.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- unexpected progress type: expected plain, auto, or tty and…
- invalid platform specified
- Refusing to push without tag or branch. Specify a…
- cannot make definite Image from unqualified PossibleImage
- unsupported os in target, abi
AI-assisted analysis of cross-rs/cross@8c1a8aa4b6 (2026-09-13).
Data as JSON: /api/errors/451aa98d98a23254.
Report an issue: GitHub.
Appendix: source
Thrown at src/docker/shared.rs:479
Running,
Paused,
Restarting,
Dead,
Exited,
DoesNotExist,
}
impl ContainerState {
pub fn new(state: &str) -> Result<Self> {
match state {
"created" => Ok(ContainerState::Created),
"running" => Ok(ContainerState::Running),
"paused" => Ok(ContainerState::Paused),
"restarting" => Ok(ContainerState::Restarting),
"dead" => Ok(ContainerState::Dead),
"exited" => Ok(ContainerState::Exited),
"" => Ok(ContainerState::DoesNotExist),
_ => eyre::bail!("unknown container state: got {state}"),
}
}
#[must_use]
pub fn is_stopped(&self) -> bool {
matches!(self, Self::Exited | Self::DoesNotExist)
}
#[must_use]
pub fn exists(&self) -> bool {
!matches!(self, Self::DoesNotExist)
}
}
// the mount directory for the data volume.
pub const MOUNT_PREFIX: &str = "/cross";
// the prefix used when naming volumes
pub const VOLUME_PREFIX: &str = "cross-";View on GitHub (pinned to 8c1a8aa4b6)