This is a small container orchestrator written in Rust using the Bollard Docker SDK.
It keeps a fixed number of containers running, replaces dead ones, and supports basic rolling updates and backoff handling.
-
Connects to the local Docker engine
-
Monitors containers with a specific service label
-
Ensures a set number of replicas (
DESIRED_REPLICAS) are always running -
Removes dead or stopped containers
-
Creates new containers when needed
-
Gracefully stops containers during scale-down or updates
-
Adds a simple backoff mechanism to avoid constant respawning
-
Supports rolling update logic using a version label
-
Rust stable toolchain
-
Docker Desktop or Docker Engine running
-
cargoto build/run the project
cargo run
If Docker isn't running, the program will keep retrying until it becomes available.
-
Stop a container manually → the orchestrator will replace it
-
Change the
IMAGEconstant → it will roll out new containers -
Kill Docker → orchestrator waits and reconnects when available
Modify these constants in main.rs:
const SERVICE_NAME: &str = "..."; const IMAGE: &str = "nginx:alpine"; const DESIRED_REPLICAS: usize = 3;
Everything is inside:
src/main.rs
No other external files are needed.