pub struct DockerClient { /* private fields */ }Expand description
A handle to a Docker daemon connection.
Wraps bollard::Docker and provides construction helpers for common
connection modes (local socket, TCP with optional TLS).
§Examples
use ironflow_ops_docker::DockerClient;
let client = DockerClient::connect_local()?;Implementations§
Source§impl DockerClient
impl DockerClient
Sourcepub fn new(docker: Docker) -> Self
pub fn new(docker: Docker) -> Self
Wrap an existing bollard::Docker connection.
§Examples
use ironflow_ops_docker::DockerClient;
use bollard::Docker;
let docker = Docker::connect_with_local_defaults()
.map_err(|e| ironflow_core::error::OperationError::External {
origin: "docker".to_string(),
message: e.to_string(),
})?;
let client = DockerClient::new(docker);Sourcepub fn connect_local() -> Result<Self, OperationError>
pub fn connect_local() -> Result<Self, OperationError>
Connect to the local Docker daemon using platform defaults.
On Unix this uses the Unix socket at /var/run/docker.sock.
On Windows this uses the named pipe.
§Errors
Returns OperationError::External if the connection cannot be
established.
§Examples
use ironflow_ops_docker::DockerClient;
let client = DockerClient::connect_local()?;Sourcepub fn connect_with_url(
url: &str,
timeout_secs: u64,
) -> Result<Self, OperationError>
pub fn connect_with_url( url: &str, timeout_secs: u64, ) -> Result<Self, OperationError>
Connect to a Docker daemon at the given host URL.
Supports unix://, tcp://, and http:// schemes.
§Errors
Returns OperationError::External if the connection cannot be
established.
§Examples
use ironflow_ops_docker::DockerClient;
let client = DockerClient::connect_with_url("tcp://localhost:2375", 120)?;Sourcepub fn from_context(_ctx: &OperationContext) -> Result<Self, OperationError>
pub fn from_context(_ctx: &OperationContext) -> Result<Self, OperationError>
Build a DockerClient from an OperationContext.
Reads docker_host from the context to determine the connection mode.
If docker_host is not set, connects to the local daemon using
platform defaults.
§Errors
Returns OperationError::External if the connection fails.
§Examples
use ironflow_ops_docker::DockerClient;
use ironflow_core::operation::{OperationContext, NoopSecretResolver};
use std::sync::Arc;
let ctx = OperationContext::new(Arc::new(NoopSecretResolver));
let client = DockerClient::from_context(&ctx)?;Sourcepub fn docker(&self) -> &Docker
pub fn docker(&self) -> &Docker
Get a reference to the underlying bollard::Docker connection.
Sourcepub fn into_inner(self) -> Docker
pub fn into_inner(self) -> Docker
Consume the client and return the underlying bollard::Docker connection.
Trait Implementations§
Source§impl Clone for DockerClient
impl Clone for DockerClient
Source§fn clone(&self) -> DockerClient
fn clone(&self) -> DockerClient
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more