pub struct Container { /* private fields */ }
Expand description

Interface for accessing and manipulating Docker Container.

Api Reference

Implementations§

source§

impl Container

source

pub fn new(docker: Docker, id: impl Into<Id>) -> Self

Exports an interface exposing operations against a Container instance.

source

pub fn id(&self) -> &Id

A getter for Container id

source§

impl Container

source

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

Api Reference

Inspect this Container.

source

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

Api Reference

Returns a stream of logs from a Container.

source

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

Api Reference

Delete this Container. Use delete to delete without options.

source

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

Api Reference

Delete this Container. Use remove to customize options.

source

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

Api Reference

Returns a top view of information about the container process. On Unix systems, this is done by running the ps command. This endpoint is not supported on Windows.

source

pub async fn attach(&self) -> Result<Multiplexer>

Api Reference

Attaches a TtyMultiplexer to the container.

The TtyMultiplexer 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

source

pub async fn changes(&self) -> Result<Option<ContainerChanges200Response>>

Api Reference

Returns a set of changes made to the container instance.

source

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

Api Reference

Exports the current docker container into a tarball.

source

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

Api Reference

Returns a stream of stats specific to this container instance.

source

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

Api Reference

Start the container instance.

source

pub async fn stop(&self, opts: &ContainerStopOpts) -> Result<()>

Api Reference

Stop the container instance.

source

pub async fn restart(&self, opts: &ContainerRestartOpts) -> Result<()>

Api Reference

Restart the container instance.

source

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

Api Reference

Kill the container instance.

source

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

Api Reference

Rename the container instance.

source

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

Api Reference

Pause the container instance.

source

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

Api Reference

Unpause the container instance.

source

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

Api Reference

Wait until the container stops.

source

pub async fn exec( &self, create_opts: &ExecCreateOpts, start_opts: &ExecStartOpts ) -> Result<Multiplexer>

Api Reference

Execute a command in this container.

source

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

Api Reference

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.

source

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

Api Reference

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.

source

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

Api Reference

Copy a tarball (see body) to the container.

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

source

pub async fn stat_file<P>(&self, path: P) -> Result<String>where P: AsRef<Path>,

Api Reference

Get information about files in a container.

source

pub async fn commit( &self, opts: &ContainerCommitOpts, config: Option<&ContainerConfig> ) -> Result<String>

Api Reference

Create a new image from this container

Trait Implementations§

source§

impl Debug for Container

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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