Skip to main content

DockerSandbox

Struct DockerSandbox 

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

Docker sandbox — the default provider.

Talks to the Docker Engine API through bollard — no docker CLI is required inside the container. This matches the playground’s deployment model: the Compose cloud service mounts the host /var/run/docker.sock (DooD) and the API is reached directly over that socket (or whatever DOCKER_HOST points at). DOCKER_HOST is honored (e.g. unix:///var/run/docker.sock or a remote tcp://…); when unset the well-known socket locations are probed.

The daemon connection is lazy: constructing a sandbox never panics and never fails, so the agent runtime (and the whole test suite) works on machines without a reachable daemon — including macOS, where Docker Desktop does not expose /var/run/docker.sock by default. The connection is established on the first spawn/exec/destroy, which then returns SandboxError::NotConfigured if no daemon could be reached.

Implementations§

Source§

impl DockerSandbox

Source

pub fn new() -> Self

Source

pub fn runtime(&self) -> Option<&str>

Return the pinned container runtime, if any (e.g. "kata"). None means the daemon’s default runtime.

Source

pub fn with_socket(path: impl Into<String>) -> Self

Pin the sandbox to one socket path (no DOCKER_HOST/auto-discovery).

Source

pub fn with_runtime(runtime: impl Into<String>) -> Self

Build a sandbox that runs containers under a specific Docker runtime (e.g. "kata"). Used by KataSandbox; reuses the same bollard client and the same SandboxResourceLimits as the default Docker provider.

Source

pub async fn client(&self) -> Result<&Docker, SandboxError>

Resolve (and memoize) the daemon client.

Trait Implementations§

Source§

impl Default for DockerSandbox

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Sandbox for DockerSandbox

Source§

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

Spawn a persistent sandbox session and return a handle.
Source§

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

Execute cmd inside a previously spawned session.
Source§

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

Tear down a sandbox session.

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more