Struct libcontainer::container::Container

source ·
pub struct Container {
    pub state: State,
    pub root: PathBuf,
}
Expand description

Structure representing the container data

Fields§

§state: State§root: PathBuf

Implementations§

source§

impl Container

source

pub fn new( container_id: &str, status: ContainerStatus, pid: Option<i32>, bundle: &Path, container_root: &Path, ) -> Result<Self, LibcontainerError>

source

pub fn id(&self) -> &str

source

pub fn can_start(&self) -> bool

source

pub fn can_kill(&self) -> bool

source

pub fn can_delete(&self) -> bool

source

pub fn can_exec(&self) -> bool

source

pub fn can_pause(&self) -> bool

source

pub fn can_resume(&self) -> bool

source

pub fn bundle(&self) -> &PathBuf

source

pub fn set_annotations( &mut self, annotations: Option<HashMap<String, String>>, ) -> &mut Self

source

pub fn pid(&self) -> Option<Pid>

source

pub fn set_pid(&mut self, pid: i32) -> &mut Self

source

pub fn created(&self) -> Option<DateTime<Utc>>

source

pub fn creator(&self) -> Option<OsString>

source

pub fn set_creator(&mut self, uid: u32) -> &mut Self

source

pub fn systemd(&self) -> bool

source

pub fn set_systemd(&mut self, should_use: bool) -> &mut Self

source

pub fn set_clean_up_intel_rdt_directory(&mut self, clean_up: bool) -> &mut Self

source

pub fn clean_up_intel_rdt_subdirectory(&self) -> Option<bool>

source

pub fn status(&self) -> ContainerStatus

source

pub fn set_status(&mut self, status: ContainerStatus) -> &mut Self

source

pub fn refresh_status(&mut self) -> Result<(), LibcontainerError>

source

pub fn refresh_state(&mut self) -> Result<&mut Self, LibcontainerError>

source

pub fn load(container_root: PathBuf) -> Result<Self, LibcontainerError>

source

pub fn save(&self) -> Result<(), LibcontainerError>

source

pub fn spec(&self) -> Result<YoukiConfig, LibcontainerError>

source§

impl Container

source§

impl Container

source

pub fn delete(&mut self, force: bool) -> Result<(), LibcontainerError>

Deletes the container

§Example
use libcontainer::container::builder::ContainerBuilder;
use libcontainer::syscall::syscall::SyscallType;

let mut container = ContainerBuilder::new(
    "74f1a4cb3801".to_owned(),
    SyscallType::default(),
)
.as_init("/var/run/docker/bundle")
.build()?;

container.delete(true)?;
source§

impl Container

source

pub fn events( &mut self, interval: u32, stats: bool, ) -> Result<(), LibcontainerError>

Displays container events

§Example
use libcontainer::container::builder::ContainerBuilder;
use libcontainer::syscall::syscall::SyscallType;

let mut container = ContainerBuilder::new(
    "74f1a4cb3801".to_owned(),
    SyscallType::default(),
)
.as_init("/var/run/docker/bundle")
.build()?;

container.events(5000, false)?;
source§

impl Container

source

pub fn kill<S: Into<Signal>>( &mut self, signal: S, all: bool, ) -> Result<(), LibcontainerError>

Sends the specified signal to the container init process

§Example
use libcontainer::container::builder::ContainerBuilder;
use libcontainer::syscall::syscall::SyscallType;
use nix::sys::signal::Signal;

let mut container = ContainerBuilder::new(
    "74f1a4cb3801".to_owned(),
    SyscallType::default(),
)
.as_init("/var/run/docker/bundle")
.build()?;

container.kill(Signal::SIGKILL, false)?;
source§

impl Container

source

pub fn pause(&mut self) -> Result<(), LibcontainerError>

Suspends all processes within the container

§Example
use libcontainer::container::builder::ContainerBuilder;
use libcontainer::syscall::syscall::SyscallType;

let mut container = ContainerBuilder::new(
    "74f1a4cb3801".to_owned(),
    SyscallType::default(),
)
.as_init("/var/run/docker/bundle")
.build()?;

container.pause()?;
source§

impl Container

source

pub fn resume(&mut self) -> Result<(), LibcontainerError>

Resumes all processes within the container

§Example
use libcontainer::container::builder::ContainerBuilder;
use libcontainer::syscall::syscall::SyscallType;

let mut container = ContainerBuilder::new(
    "74f1a4cb3801".to_owned(),
    SyscallType::default(),
)
.as_init("/var/run/docker/bundle")
.build()?;

container.resume()?;
source§

impl Container

source

pub fn start(&mut self) -> Result<(), LibcontainerError>

Starts a previously created container

§Example
use libcontainer::container::builder::ContainerBuilder;
use libcontainer::syscall::syscall::SyscallType;

let mut container = ContainerBuilder::new(
    "74f1a4cb3801".to_owned(),
    SyscallType::default(),
)
.as_init("/var/run/docker/bundle")
.build()?;

container.start();

Trait Implementations§

source§

impl Clone for Container

source§

fn clone(&self) -> Container

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for Container

source§

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

Formats the value using the given formatter. Read more
source§

impl Default for Container

source§

fn default() -> Self

Returns the “default value” for a type. 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, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> 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.
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