pub async fn create_runtime(
config: RuntimeConfig,
auth_ctx: Option<ContainerAuthContext>,
) -> Result<Arc<dyn Runtime + Send + Sync>>Expand description
Create a runtime based on the provided configuration
§Arguments
config- The runtime configuration specifying which runtime to use
§Returns
An Arc<dyn Runtime + Send + Sync> that can be used with ServiceManager
§Errors
Returns AgentError if the runtime cannot be initialized (e.g., failed to create
required directories, no runtime available for Auto mode)
§Runtime Selection for Auto Mode
When RuntimeConfig::Auto is specified:
- Linux: Uses bundled libcontainer runtime (no external binary needed), falls back to Docker
- macOS: Uses sandbox runtime (native Metal/MPS), falls back to VM runtime (libkrun), then Docker
- Windows: Uses Docker directly
- If no runtime can be initialized, returns an error
§Example
use zlayer_agent::{RuntimeConfig, create_runtime};
let runtime = create_runtime(RuntimeConfig::Auto, None).await?;