Skip to main content

ContainerSpec

Struct ContainerSpec 

Source
pub struct ContainerSpec {
    pub name: String,
    pub image: String,
    pub env: Vec<(String, String)>,
    pub command: Option<Vec<String>>,
    pub ports: Vec<PortBinding>,
    pub mounts: Vec<FileMount>,
    pub network_id: Option<String>,
    pub aliases: Vec<String>,
    pub run_id: String,
    pub memory_limit_mb: Option<u64>,
    pub keep_alive: bool,
    pub checkpoint_ref: Option<String>,
}
Expand description

Everything a backend needs to create one container. Host ports in ports are already chosen by the core allocator (see free_ports) — a backend binds them, it never allocates, so the same spec works identically whether the backend is a microVM or a Docker daemon.

Fields§

§name: String

The backend-facing container name, e.g. rz-<run_id>-<seq>.

§image: String

The image reference to run.

§env: Vec<(String, String)>

Environment variables, insertion-ordered — a Vec of pairs rather than a HashMap so order and duplicate-key handling stay under the caller’s control.

§command: Option<Vec<String>>

The command to run instead of the image’s default entrypoint. None means “run the image as built.”

§ports: Vec<PortBinding>

Already-chosen host↔guest port bindings — see the type-level doc.

§mounts: Vec<FileMount>

Host files/directories to mount into the guest.

§network_id: Option<String>

The network to join, if any.

§aliases: Vec<String>

DNS-style aliases this container is reachable as by other members of its network.

§run_id: String

The per-process run id (see run_id), used to label/name containers so a crashed run’s leftovers can be told apart from a live run’s.

§memory_limit_mb: Option<u64>

An optional memory cap in megabytes.

§keep_alive: bool

Marks this container as a reuse sandbox — one meant to outlive this process’s own lifecycle rather than be torn down by it. Defaults to false; no builder in this crate sets it yet (reuse itself is a later wave), but every own-run cleanup path (the reaping ledger’s .sandboxes file, the msb backend’s started_names, the docker backend’s run-id label, this crate’s Drop-path cleanup) already knows to leave a keep_alive spec’s container alone, so wiring the field in now costs nothing and the reuse wave doesn’t need to touch any of those call sites again.

§checkpoint_ref: Option<String>

Set by crate::Container::from_checkpoint to the source crate::Checkpoint’s ref — the checkpoint feature’s own signal to the backend that this spec’s image is a checkpoint reference, not an ordinary image. docker ignores this (the ref already IS a normal image tag; the ordinary create path just works); microsandbox, when this is set, boots via msb run --snapshot <ref> instead of its normal image boot, keeping every other flag identical. Deliberately NOT part of the reuse identity hash — reuse and from_checkpoint are not a supported combination (see RightsizeError::ReuseCheckpointConflict). Defaults to None.

Implementations§

Source§

impl ContainerSpec

Source

pub fn new( name: impl Into<String>, image: impl Into<String>, run_id: impl Into<String>, ) -> Self

Builds a spec with every optional field at its default (no env, no command, no ports, no mounts, no network, no aliases, no memory limit).

Trait Implementations§

Source§

impl Clone for ContainerSpec

Source§

fn clone(&self) -> ContainerSpec

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ContainerSpec

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.