Skip to main content

DockerBackend

Struct DockerBackend 

Source
pub struct DockerBackend { /* private fields */ }
Expand description

Drives the Docker daemon over DockerClient. See the module docs for the shape.

Implementations§

Source§

impl DockerBackend

Source

pub fn connecting_to_env() -> Self

Builds a backend pointed at the daemon DOCKER_HOST (or the default socket) names — the same resolution crate::DockerBackendProvider’s create uses, exposed directly for callers that want a concrete DockerBackend without going through rightsize::backends::resolve (integration tests, mainly).

Trait Implementations§

Source§

impl SandboxBackend for DockerBackend

Source§

fn name(&self) -> &str

The backend’s human id, e.g. "docker" / "microsandbox" — shown in errors and matched against RIGHTSIZE_BACKEND.
Source§

fn supports_native_networks(&self) -> bool

True when the runtime has real container networks; false means network links are emulated (see SandboxBackend::install_network_links).
Source§

fn create<'life0, 'async_trait>( &'life0 self, spec: ContainerSpec, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn SandboxHandle>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Creates (but does not start) a container from spec. spec.ports are already chosen — this call binds them, it never allocates.
Source§

fn start<'life0, 'life1, 'async_trait>( &'life0 self, handle: &'life1 dyn SandboxHandle, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Starts a container previously returned by SandboxBackend::create.
Source§

fn stop<'life0, 'life1, 'async_trait>( &'life0 self, handle: &'life1 dyn SandboxHandle, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Stops a running container. Safe to call on an already-stopped one.
Source§

fn remove<'life0, 'life1, 'async_trait>( &'life0 self, handle: &'life1 dyn SandboxHandle, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Removes a stopped container’s resources.
Source§

fn exec<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, handle: &'life1 dyn SandboxHandle, cmd: &'life2 [String], ) -> Pin<Box<dyn Future<Output = Result<ExecResult>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Runs cmd inside the running container and returns its exit code plus captured output.
Source§

fn logs<'life0, 'life1, 'async_trait>( &'life0 self, handle: &'life1 dyn SandboxHandle, ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

The container’s full captured logs so far.
Source§

fn follow_logs<'life0, 'life1, 'async_trait>( &'life0 self, handle: &'life1 dyn SandboxHandle, consumer: Box<dyn Fn(String) + Send + Sync>, ) -> Pin<Box<dyn Future<Output = Result<FollowHandle>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Streams log lines to consumer as they arrive. Read more
Source§

fn ensure_network<'life0, 'life1, 'async_trait>( &'life0 self, network_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Creates the named network if the runtime needs an explicit create step; no-op otherwise.
Source§

fn remove_network<'life0, 'life1, 'async_trait>( &'life0 self, network_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Removes the named network; no-op for runtimes with nothing to remove.
Source§

fn close<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Best-effort teardown of backend-owned resources (client sockets, etc.), called once when the backend itself is being retired — not per-container.
Source§

fn cleanup_sync(&self, container_id: &str)

SYNCHRONOUS SIGKILL-safe teardown for the Drop-path cleanup thread (see crate::cleanup). Given a container id/name, tears it down with blocking std I/O only — never Tokio, never block_on — because this runs on a dedicated OS thread with no async runtime in context. Called only from that thread, never from async code.
Called after start, before the wait strategy runs, to make links reachable from handle by alias. 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> 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, 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.