Struct docker_api::docker::Docker

source ·
pub struct Docker { /* private fields */ }
Expand description

Entrypoint interface for communicating with docker daemon

Implementations§

source§

impl Docker

source

pub async fn version(&self) -> Result<SystemVersion>

Api Reference

Returns the version of Docker that is running and various information about the system that Docker is running on.

source

pub async fn info(&self) -> Result<SystemInfo>

Api Reference

Returns system information about Docker instance that is running

source

pub async fn ping(&self) -> Result<PingInfo>

Api Reference

This is a dummy endpoint you can use to test if the server is accessible

source

pub fn events<'docker>( &'docker self, opts: &EventsOpts ) -> impl Stream<Item = Result<EventMessage>> + Unpin + 'docker

Api Reference

Returns a stream of Docker events

source

pub async fn data_usage( &self, opts: &SystemDataUsageOpts ) -> Result<SystemDataUsage200Response>

Api Reference

Returns data usage of this Docker instance

source§

impl Docker

source

pub fn new(uri: impl AsRef<str>) -> Result<Self>

Creates a new Docker instance by automatically choosing appropriate connection type based on provided uri.

Supported schemes are:

  • unix:// only works when build target is unix, otherwise returns an Error
  • tcp://
  • http://

To create a Docker instance utilizing TLS use explicit Docker::tls constructor (this requires tls feature enabled).

This creates an unversioned connector that’ll use the latest server version, to use a specific version see Docker::unix_versioned.

source

pub fn new_versioned( uri: impl AsRef<str>, version: impl Into<ApiVersion> ) -> Result<Self>

Same as Docker::new but the API version can be explicitly specified.

source

pub fn unix(socket_path: impl AsRef<Path>) -> Self

Available on Unix only.

Creates a new docker instance for a docker host listening on a given Unix socket.

socket_path is the part of URI that comes after the unix://. For example a URI unix:///run/docker.sock has a socket_path == “/run/docker.sock”.

This creates an unversioned connector that’ll use the latest server version, to use a specific version see Docker::unix_versioned.

source

pub fn unix_versioned( socket_path: impl AsRef<Path>, version: impl Into<ApiVersion> ) -> Self

Available on Unix only.

Same as Docker::unix but the API version can be explicitly specified.

source

pub fn tls( host: impl AsRef<str>, cert_path: impl AsRef<Path>, verify: bool ) -> Result<Self>

Available on crate feature tls only.

Creates a new docker instance for a docker host listening on a given TCP socket host. host is the part of URI that comes after tcp:// or http:// or https:// schemes, also known as authority part.

cert_path specifies the base path in the filesystem containing a certificate (cert.pem) and a key (key.pem) that will be used by the client. If verify is true a CA file will be added (ca.pem) to the connector.

Returns an error if the provided host will fail to parse as URL or reading the certificate files will fail.

This creates an unversioned connector that’ll use the latest server version, to use a specific version see Docker::unix_versioned.

source

pub fn tls_versioned( host: impl AsRef<str>, version: impl Into<ApiVersion>, cert_path: impl AsRef<Path>, verify: bool ) -> Result<Self>

Available on crate feature tls only.

Same as Docker::tls but the API version can be explicitly specified.

source

pub fn tcp(host: impl AsRef<str>) -> Result<Self>

Creates a new docker instance for a docker host listening on a given TCP socket host. host is the part of URI that comes after tcp:// or http:// schemes, also known as authority part.

TLS is supported with feature tls enabled through Docker::tls constructor.

Returns an error if the provided host will fail to parse as URL.

This creates an unversioned connector that’ll use the latest server version, to use a specific version see Docker::unix_versioned.

source

pub fn tcp_versioned( host: impl AsRef<str>, version: impl Into<ApiVersion> ) -> Result<Self>

Same as Docker::tcp but the API version can be explicitly specified.

source

pub fn images(&self) -> Images

Exports an interface for interacting with Docker images

source

pub fn containers(&self) -> Containers

Exports an interface for interacting with Docker containers

source

pub fn networks(&self) -> Networks

Exports an interface for interacting with Docker networks

source

pub fn volumes(&self) -> Volumes

Exports an interface for interacting with Docker volumes

source

pub async fn adjust_api_version(&mut self) -> Result<()>

Verifies the API version returned by the server and adjusts the version used by this client in future requests.

source§

impl Docker

source

pub fn services(&self) -> Services

Exports an interface for interacting with Docker services.

source

pub fn configs(&self) -> Configs

Exports an interface for interacting with Docker configs.

source

pub fn tasks(&self) -> Tasks

Exports an interface for interacting with Docker tasks.

source

pub fn secrets(&self) -> Secrets

Exports an interface for interacting with Docker secrets.

source

pub fn swarm(&self) -> Swarm

Exports an interface for interacting with Docker swarm.

source

pub fn nodes(&self) -> Nodes

Exports an interface for interacting with Docker nodes.

source

pub fn plugins(&self) -> Plugins

Exports an interface for interacting with Docker plugins.

Trait Implementations§

source§

impl Clone for Docker

source§

fn clone(&self) -> Docker

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 Docker

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Docker

§

impl Send for Docker

§

impl Sync for Docker

§

impl Unpin for Docker

§

impl !UnwindSafe for Docker

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> ToOwned for Twhere T: Clone,

§

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