docker-wrapper 0.4.0

A Docker CLI wrapper for Rust
Documentation

docker-wrapper

Crates.io Documentation CI License: MIT

A comprehensive, type-safe Docker CLI wrapper for Rust applications.

Features

  • Complete Docker CLI coverage (35+ commands)
  • Type-safe builder pattern API
  • Async/await support with Tokio
  • Real-time output streaming
  • Docker Compose support (optional)
  • Zero unsafe code
  • Extensive test coverage

Installation

[dependencies]
docker-wrapper = "0.2"
tokio = { version = "1", features = ["full"] }

Enable Docker Compose support:

[dependencies]
docker-wrapper = { version = "0.2", features = ["compose"] }

Quick Start

use docker_wrapper::{DockerCommand, RunCommand};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Run a container
    let output = RunCommand::new("nginx:latest")
        .name("my-web-server")
        .port(8080, 80)
        .detach()
        .execute()
        .await?;

    println!("Container started: {}", output.container_id);
    Ok(())
}

When to Use docker-wrapper

docker-wrapper is ideal for:

  • CLI tools and automation scripts - Familiar Docker CLI behavior
  • Docker Compose workflows - Native compose command support
  • Development tools - Container management for dev environments
  • Shell script migration - Type-safe Rust alternative to bash scripts
  • Cross-platform support - Works with Docker, Podman, Colima, etc.

Choosing between Docker Rust libraries? See our comprehensive Comparison Guide comparing docker-wrapper vs bollard vs testcontainers-rs.

Documentation

For comprehensive documentation, examples, and API reference:

Examples

The examples/ directory contains practical examples:

  • basic_usage.rs - Common Docker operations
  • container_lifecycle.rs - Container management
  • streaming.rs - Real-time output streaming
  • docker_compose.rs - Docker Compose usage (requires compose feature)
  • error_handling.rs - Error handling patterns

Run examples:

cargo run --example basic_usage
cargo run --example streaming
cargo run --features compose --example docker_compose

Contributing

Contributions are welcome! Please see our Contributing Guide for details.

License

Licensed under the MIT license (LICENSE or http://opensource.org/licenses/MIT).