Giter Site home page Giter Site logo

compose-rs's Introduction

compose-rs

compose-rs is a Rust library designed to manage Docker Compose environments programmatically. It provides a straightforward API for executing common Docker Compose commands directly from Rust code.

Features

  • Easy Setup: Quickly configure your Docker Compose path and start managing containers.
  • Command Execution: Support for basic Docker Compose commands like up, down, ps, and stats.
  • Stream Stats: Stream statistics of services in real-time.

Installation

Add to your Cargo.toml:

[dependencies]
+ compose-rs = "0.0.3"

Quick Start

This example demonstrates how to bring up a Docker Compose environment and monitor the stats of running services in real-time.

use compose_rs::{Compose, ComposeCommand};

fn main() {
    let compose = Compose::builder()
        .path("docker-compose.yml")
        .build()
        .unwrap();

    // Execute the `up` command to start services defined in the Docker Compose file
    if let Err(e) = compose.up().exec() {
        eprintln!("Error starting services: {}", e);
    }

    // Stream stats and print them in real-time for each service
    compose
        .stats()
        .stream()
        .unwrap()
        .into_iter()
        .for_each(|service| {
            println!("{:?}", service);
        });

    // After monitoring, bring down the services
    if let Err(e) = compose.down().exec() {
        println!("Error stopping services: {}", e);
    }
}

Documentation

For detailed API documentation and advanced usage, please refer to the generated documentation.

Contributing

Contributions are welcome! Please feel free to contribute by opening issues or submitting pull requests.

License

compose-rs is licensed under the MIT license. See LICENSE for details.

compose-rs's People

Contributors

tomvoet avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.