pub struct ContainerHardening {
pub drop_capabilities: bool,
pub no_new_privileges: bool,
pub read_only_rootfs: bool,
pub pids_limit: Option<u32>,
pub memory: Option<String>,
pub cpus: Option<String>,
}Expand description
What ContainerRuntime asks the engine to enforce on each agent.
This is the cheap 80% of isolation: a handful of create flags that remove
the capabilities an HTTP server never needs and bound what a misbehaving one
can consume. It is not a sandbox against code written to escape — that
would be a microVM, and it is deliberately not what this is. Until you have
one, describe a container-run agent as contained, not isolated.
The defaults are the ones that cannot break a working agent. Resource
limits are not among them: there is no memory ceiling that is right for
every agent, and one guessed here would show up as an agent that dies under
load for no visible reason. They are opt-in, per deployment
(with_memory, with_cpus).
Fields§
§drop_capabilities: boolDrop every Linux capability. An agent binds a port above 1024 and talks HTTP; it needs none of them.
no_new_privileges: boolForbid gaining privileges through setuid binaries (no-new-privileges).
read_only_rootfs: boolMount the root filesystem read-only where the agent’s config allows
it — see [needs_writable_rootfs]. A /tmp tmpfs is mounted alongside
so an agent still has scratch space.
pids_limit: Option<u32>Cap on processes in the container.
memory: Option<String>Memory ceiling, in the engine’s own notation ("512m", "2g").
Passed through verbatim — the engine is the authority on the format.
cpus: Option<String>CPU allowance, in the engine’s own notation ("0.5", "2").
Implementations§
Source§impl ContainerHardening
impl ContainerHardening
Sourcepub fn none() -> Self
pub fn none() -> Self
Every restriction off — containers as they were before hardening.
The escape hatch for an agent that genuinely needs what the defaults
remove (a handler writing outside /tmp, an image with a setuid helper).
Prefer narrowing one field of Default to reaching for this.
Sourcepub fn with_memory(self, memory: impl Into<String>) -> Self
pub fn with_memory(self, memory: impl Into<String>) -> Self
Set the memory ceiling (engine notation, e.g. "512m").
Trait Implementations§
Source§impl Clone for ContainerHardening
impl Clone for ContainerHardening
Source§impl Debug for ContainerHardening
impl Debug for ContainerHardening
Auto Trait Implementations§
impl Freeze for ContainerHardening
impl RefUnwindSafe for ContainerHardening
impl Send for ContainerHardening
impl Sync for ContainerHardening
impl Unpin for ContainerHardening
impl UnsafeUnpin for ContainerHardening
impl UnwindSafe for ContainerHardening
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 more