pub struct Container { /* private fields */ }
Expand description
Interface for accessing and manipulating Docker Container.
Implementations§
Source§impl Container
impl Container
Sourcepub async fn inspect(&self) -> Result<ContainerInspect200Response>
pub async fn inspect(&self) -> Result<ContainerInspect200Response>
Inspect this Container.
Sourcepub fn logs<'docker>(
&'docker self,
opts: &LogsOpts,
) -> impl Stream<Item = Result<TtyChunk>> + Unpin + 'docker
pub fn logs<'docker>( &'docker self, opts: &LogsOpts, ) -> impl Stream<Item = Result<TtyChunk>> + Unpin + 'docker
Returns a stream of logs from a Container.
Sourcepub async fn remove(&self, opts: &ContainerRemoveOpts) -> Result<String>
pub async fn remove(&self, opts: &ContainerRemoveOpts) -> Result<String>
Delete this Container.
Use delete
to delete without options.
Sourcepub async fn delete(&self) -> Result<String>
pub async fn delete(&self) -> Result<String>
Delete this Container.
Use remove
to customize options.
Sourcepub async fn top(&self, psargs: Option<&str>) -> Result<ContainerTop200Response>
pub async fn top(&self, psargs: Option<&str>) -> Result<ContainerTop200Response>
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.
Sourcepub async fn attach(&self) -> Result<Multiplexer>
pub async fn attach(&self) -> Result<Multiplexer>
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
Sourcepub async fn changes(&self) -> Result<Option<ContainerChanges200Response>>
pub async fn changes(&self) -> Result<Option<ContainerChanges200Response>>
Returns a set of changes made to the container instance.
Sourcepub fn export(&self) -> impl Stream<Item = Result<Vec<u8>>> + '_
pub fn export(&self) -> impl Stream<Item = Result<Vec<u8>>> + '_
Exports the current docker container into a tarball.
Sourcepub fn stats(&self) -> impl Stream<Item = Result<Value>> + Unpin + '_
pub fn stats(&self) -> impl Stream<Item = Result<Value>> + Unpin + '_
Returns a stream of stats specific to this container instance.
Sourcepub async fn stop(&self, opts: &ContainerStopOpts) -> Result<()>
pub async fn stop(&self, opts: &ContainerStopOpts) -> Result<()>
Stop the container instance.
Sourcepub async fn restart(&self, opts: &ContainerRestartOpts) -> Result<()>
pub async fn restart(&self, opts: &ContainerRestartOpts) -> Result<()>
Restart the container instance.
Sourcepub async fn wait(&self) -> Result<ContainerWaitResponse>
pub async fn wait(&self) -> Result<ContainerWaitResponse>
Wait until the container stops.
Sourcepub async fn exec(
&self,
create_opts: &ExecCreateOpts,
start_opts: &ExecStartOpts,
) -> Result<Multiplexer>
pub async fn exec( &self, create_opts: &ExecCreateOpts, start_opts: &ExecStartOpts, ) -> Result<Multiplexer>
Execute a command in this container.
Sourcepub fn copy_from(
&self,
path: impl AsRef<Path>,
) -> impl Stream<Item = Result<Vec<u8>>> + '_
pub fn copy_from( &self, path: impl AsRef<Path>, ) -> impl Stream<Item = Result<Vec<u8>>> + '_
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.
Sourcepub async fn copy_file_into<P: AsRef<Path>>(
&self,
path: P,
bytes: &[u8],
) -> Result<()>
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.
Sourcepub async fn copy_to(&self, path: &Path, body: Body) -> Result<()>
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
).
Sourcepub async fn stat_file<P>(&self, path: P) -> Result<String>
pub async fn stat_file<P>(&self, path: P) -> Result<String>
Get information about files in a container.
Sourcepub async fn commit(
&self,
opts: &ContainerCommitOpts,
config: Option<&ContainerConfig>,
) -> Result<String>
pub async fn commit( &self, opts: &ContainerCommitOpts, config: Option<&ContainerConfig>, ) -> Result<String>
Create a new image from this container