Struct Container

Source
pub struct Container<'docker> { /* private fields */ }
Expand description

Interface for accessing and manipulating a docker container

Api Reference

Implementations§

Source§

impl<'docker> Container<'docker>

Source

pub fn new<S>(docker: &'docker Docker, id: S) -> Self
where S: Into<String>,

Exports an interface exposing operations against a container instance

Source

pub fn id(&self) -> &str

a getter for the container id

Source

pub async fn inspect(&self) -> Result<ContainerDetails>

Inspects the current docker container instance’s details

Api Reference

Source

pub async fn top(&self, psargs: Option<&str>) -> Result<Top>

Returns a top view of information about the container process

Api Reference

Source

pub fn logs( &self, opts: &LogsOptions, ) -> impl Stream<Item = Result<TtyChunk>> + Unpin + 'docker

Returns a stream of logs emitted but the container instance

Api Reference

Source

pub async fn attach(&self) -> Result<TtyMultiPlexer<'docker>>

Attaches a Multiplexer to the container.

The Multiplexer implements Stream for returning Stdout and Stderr chunks. It also implements [AsyncWrite] for writing to Stdin.

The multiplexer can be split into its read and write halves with the split method

Api Reference

Source

pub async fn changes(&self) -> Result<Vec<Change>>

Returns a set of changes made to the container instance

Api Reference

Source

pub fn export(&self) -> impl Stream<Item = Result<Vec<u8>>> + 'docker

Exports the current docker container into a tarball

Api Reference

Source

pub fn stats(&self) -> impl Stream<Item = Result<Stats>> + Unpin + 'docker

Returns a stream of stats specific to this container instance

Api Reference

Source

pub async fn start(&self) -> Result<()>

Start the container instance

Api Reference

Source

pub async fn stop(&self, wait: Option<Duration>) -> Result<()>

Stop the container instance

Api Reference

Source

pub async fn restart(&self, wait: Option<Duration>) -> Result<()>

Restart the container instance

Api Reference

Source

pub async fn kill(&self, signal: Option<&str>) -> Result<()>

Kill the container instance

Api Reference

Source

pub async fn rename(&self, name: &str) -> Result<()>

Rename the container instance

Api Reference

Source

pub async fn pause(&self) -> Result<()>

Pause the container instance

Api Reference

Source

pub async fn unpause(&self) -> Result<()>

Unpause the container instance

Api Reference

Source

pub async fn wait(&self) -> Result<Exit>

Wait until the container stops

Api Reference

Source

pub async fn delete(&self) -> Result<()>

Delete the container instance

Use remove instead to use the force/v options.

Api Reference

Source

pub async fn remove(&self, opts: RmContainerOptions) -> Result<()>

Delete the container instance (todo: force/v)

Api Reference

Source

pub fn exec( &self, opts: &ExecContainerOptions, ) -> impl Stream<Item = Result<TtyChunk>> + Unpin + 'docker

Execute a command in this container

Api Reference

Source

pub fn copy_from( &self, path: &Path, ) -> impl Stream<Item = Result<Vec<u8>>> + 'docker

Copy a file/folder from the container. The resulting stream is a tarball of the extracted files.

If path is not an absolute path, it is relative to the container’s root directory. The resource specified by path must exist. To assert that the resource is expected to be a directory, path should end in / or /. (assuming a path separator of /). If path ends in /. then this indicates that only the contents of the path directory should be copied. A symlink is always resolved to its target.

Api Reference

Source

pub async fn copy_file_into<P: AsRef<Path>>( &self, path: P, bytes: &[u8], ) -> Result<()>

Copy a byte slice as file into (see bytes) the container.

The file will be copied at the given location (see path) and will be owned by root with access mask 644.

Api Reference

Source

pub async fn copy_to(&self, path: &Path, body: Body) -> Result<()>

Copy a tarball (see body) to the container.

The tarball will be copied to the container and extracted at the given location (see path).

Api Reference

Auto Trait Implementations§

§

impl<'docker> Freeze for Container<'docker>

§

impl<'docker> !RefUnwindSafe for Container<'docker>

§

impl<'docker> Send for Container<'docker>

§

impl<'docker> Sync for Container<'docker>

§

impl<'docker> Unpin for Container<'docker>

§

impl<'docker> !UnwindSafe for Container<'docker>

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

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T