pub struct DockerConfig {
pub image: String,
pub work_dir: String,
pub setup_commands: Vec<String>,
pub environment: Vec<String>,
pub bind_mounts: Vec<String>,
pub network_disabled: bool,
pub container_name_prefix: String,
pub auto_start: bool,
pub auto_remove: bool,
pub drop_capabilities: bool,
pub no_new_privileges: bool,
pub pids_limit: Option<u32>,
}Expand description
Configuration for the Docker executor.
§Example
use adk_code::DockerConfig;
let config = DockerConfig::python();
assert_eq!(config.image, "python:3.12-slim");
assert_eq!(config.work_dir, "/workspace");Fields§
§image: StringContainer image to use.
work_dir: StringWorking directory inside the container.
setup_commands: Vec<String>Setup commands to run after container creation (e.g., pip install).
environment: Vec<String>Extra environment variables to set in the container.
bind_mounts: Vec<String>Bind mounts in host:container[:ro] format.
network_disabled: boolWhether to disable network access.
container_name_prefix: StringContainer name prefix (a random suffix is appended).
auto_start: boolWhether to auto-start on first execute if not already running.
auto_remove: boolWhether to auto-stop and remove the container on drop.
drop_capabilities: boolDrop every Linux capability (CapDrop: ["ALL"]). Default: true.
Setup commands that switch users, such as apt-get, need it turned off.
no_new_privileges: boolForbid gaining privileges, such as through setuid binaries
(SecurityOpt: ["no-new-privileges"]). Default: true.
pids_limit: Option<u32>Most processes the container may run (PidsLimit), which stops a fork bomb;
None sets no limit. Default: DEFAULT_PIDS_LIMIT.
Implementations§
Source§impl DockerConfig
impl DockerConfig
Sourcepub fn setup_command(self, cmd: impl Into<String>) -> Self
pub fn setup_command(self, cmd: impl Into<String>) -> Self
Add a setup command to run after container creation.
Sourcepub fn pip_install(self, packages: &[&str]) -> Self
pub fn pip_install(self, packages: &[&str]) -> Self
Add a pip install command for Python dependencies.
Sourcepub fn npm_install(self, packages: &[&str]) -> Self
pub fn npm_install(self, packages: &[&str]) -> Self
Add an npm install command for Node.js dependencies.
Sourcepub fn with_network(self) -> Self
pub fn with_network(self) -> Self
Enable network access (disabled by default).
Sourcepub fn bind_mount(self, mount: impl Into<String>) -> Self
pub fn bind_mount(self, mount: impl Into<String>) -> Self
Add a bind mount.
Sourcepub fn validate_sandbox_policy(
&self,
policy: &SandboxPolicy,
) -> Result<(), ExecutionError>
pub fn validate_sandbox_policy( &self, policy: &SandboxPolicy, ) -> Result<(), ExecutionError>
Checks that a container created from this configuration satisfies policy.
A persistent container’s network mode, bind mounts, and environment are
fixed when it is created, so a request cannot narrow them afterwards.
DockerExecutor calls this before every execution and rejects a request
whose policy is stricter than the container:
| Policy | Satisfied when |
|---|---|
NetworkPolicy::Disabled | network_disabled is true |
FilesystemPolicy::None | there are no bind mounts |
FilesystemPolicy::WorkspaceReadOnly { root } | every bind mount is read-only (:ro) and its host path lies under root |
FilesystemPolicy::WorkspaceReadWrite { root } | every bind mount’s host path lies under root |
FilesystemPolicy::Paths { read_only, read_write } | every bind mount lies under a read_write path, or is read-only and lies under a read_only path |
EnvironmentPolicy::None | environment is empty |
EnvironmentPolicy::AllowList(names) | every environment entry’s name is in names |
Bind-mount host paths must be absolute and free of .. components, so a
named volume never satisfies a filesystem policy. Variables defined by the
image itself (PATH, LANG) come from the image, not the host, and are
not checked.
§Errors
Returns ExecutionError::UnsupportedPolicy naming the first setting
that exceeds the policy.
§Example
use adk_code::{DockerConfig, NetworkPolicy, SandboxPolicy};
let strict = SandboxPolicy::strict_rust();
assert!(DockerConfig::python().validate_sandbox_policy(&strict).is_ok());
// A networked container cannot honour a request that disables the network.
let networked = DockerConfig::python().with_network();
assert!(networked.validate_sandbox_policy(&strict).is_err());
let allows_network = SandboxPolicy { network: NetworkPolicy::Enabled, ..strict };
assert!(networked.validate_sandbox_policy(&allows_network).is_ok());Trait Implementations§
Source§impl Clone for DockerConfig
impl Clone for DockerConfig
Source§impl Debug for DockerConfig
impl Debug for DockerConfig
Auto Trait Implementations§
impl Forget for DockerConfig
impl Freeze for DockerConfig
impl Move for DockerConfig
impl RefUnwindSafe for DockerConfig
impl Send for DockerConfigwhere
RawVecInner: Send,
impl Sync for DockerConfigwhere
RawVecInner: Sync,
impl Unpin for DockerConfig
impl UnsafeUnpin for DockerConfigwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
impl UnwindSafe for DockerConfigwhere
RawVecInner: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreimpl<T> MaybeSendSync for T
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.