Crate lmrc_docker

Crate lmrc_docker 

Source
Expand description

§Docker Client

A comprehensive, ergonomic Docker client library for Rust built on top of Bollard.

§Features

  • Full Docker API Coverage: Containers, images, networks, and volumes
  • Fluent Builder APIs: Ergonomic, chainable methods for creating resources
  • Async/Await: Built on Tokio for modern async Rust
  • Type-Safe: Leverage Rust’s type system for compile-time safety
  • Well Documented: Comprehensive documentation and examples

§Quick Start

use lmrc_docker::DockerClient;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Create a client
    let client = DockerClient::new()?;

    // Check Docker is available
    client.ping().await?;

    // Pull an image
    client.images().pull("nginx:latest", None).await?;

    // Create and start a container
    let container = client.containers()
        .create("nginx:latest")
        .name("web-server")
        .port(8080, 80, "tcp")
        .env("ENV", "production")
        .build()
        .await?;

    container.start().await?;

    // List running containers
    let containers = client.containers().list(false).await?;
    println!("Running {} containers", containers.len());

    // Stop and remove the container
    container.stop(Some(10)).await?;
    container.remove(false, false).await?;

    Ok(())
}

§Modules

  • client: Docker client configuration and connection
  • containers: Container lifecycle management
  • images: Image operations (build, pull, push, etc.)
  • networks: Network management
  • volumes: Volume operations
  • registry: Registry operations (search, authentication, image management)
  • error: Error types and result aliases

Re-exports§

pub use client::DockerClient;
pub use client::DockerClientConfig;
pub use containers::ContainerBuilder;
pub use containers::ContainerRef;
pub use containers::Containers;
pub use error::DockerError;
pub use error::Result;
pub use images::ImageBuilder;
pub use images::ImageRef;
pub use images::Images;
pub use networks::NetworkRef;
pub use networks::Networks;
pub use registry::ImageSearchResult;
pub use registry::Registry;
pub use registry::RegistryConfig;
pub use volumes::VolumeRef;
pub use volumes::Volumes;

Modules§

client
Docker client configuration and connection management.
containers
Container management operations.
error
Error types for the docker-client library.
images
Image management operations.
networks
Network management operations.
registry
volumes
Volume management operations.

Structs§

ContainerInspectResponse
ContainerSummary
DockerCredentials
DockerCredentials credentials and server URI to push images using the Push Image API or the Build Image API.
ImageInspect
Information about an image in the local image cache.
ImageSummary
Network
Volume