Expand description
§nanodock
Zero-dependency-light Docker/Podman daemon client for container detection, port mapping, and lifecycle control.
§Module structure
api- JSON response parsing and container name resolution.http- Minimal HTTP/1.0 response parser (headers viahttparse).ipc- OS-specific transport (Unix socket, Windows named pipe, TCP).podman- Rootless Podman resolver via overlay metadata (Linux only).
§Quick start
§Best-effort path (background thread, never errors)
use nanodock::{start_detection, await_detection};
let handle = start_detection(None);
// ... do other work while detection runs in the background ...
let port_map = await_detection(handle);
for ((ip, port, proto), info) in &port_map {
println!("{proto} port {port} -> {} ({})", info.name, info.image);
}§Strict path (synchronous, returns errors)
use nanodock::detect_containers;
match detect_containers(None) {
Ok(port_map) => {
for ((ip, port, proto), info) in &port_map {
println!("{proto} port {port} -> {} ({})", info.name, info.image);
}
}
Err(e) => eprintln!("detection failed: {e}"),
}Structs§
- Container
Info - Metadata about a running container that has published ports.
- Detection
Handle - Handle for an in-progress Docker/Podman container detection.
- Rootless
Podman Resolver - Cache for rootless Podman container lookups keyed by process and network namespace.
Enums§
- Error
- Error returned by
detect_containerswhen the daemon cannot be reached or returns an unusable response. - Protocol
- Network transport protocol.
- Published
Container Match - Result of matching a socket against published container port bindings.
- Stop
Outcome - Result of attempting to stop or kill a container via the daemon API.
Functions§
- await_
detection - Wait for Docker/Podman detection to complete.
- detect_
containers - Synchronously detect Docker/Podman containers and their published ports.
- is_
podman_ rootlessport_ process - Check whether a process name matches the Podman rootless port-forwarder.
- lookup_
published_ container - Match a local socket against known published container bindings.
- lookup_
rootless_ podman_ container - Resolve a rootless Podman
rootlessporthelper process back to its container. - parse_
containers_ json - Parse the JSON response from
GET /containers/jsoninto a port map. - parse_
containers_ json_ strict - Strict variant of
parse_containers_jsonthat propagates JSON deserialization errors instead of silently returning an empty map. - short_
container_ id - Truncate a full container ID to its 12-character short form.
- start_
detection - Start asynchronous detection of Docker/Podman containers.
- stop_
container - Stop or kill a running container via the Docker/Podman daemon API.
Type Aliases§
- Container
Port Map - Maps
(host_ip, host_port, protocol)to container info.