Docktopus
A high-performance Rust library for programmatic container orchestration, offering type-safe Docker and Docker Compose operations with advanced deployment capabilities.
Overview
Docktopus bridges the gap between static container configurations and dynamic runtime orchestration. It provides a robust, type-safe interface for programmatically managing containers, with first-class support for both Dockerfile and Docker Compose workflows.
Key Features
🔒 Type-Safe Container Orchestration
- Compile-time Validation: Catch configuration errors before deployment with Rust's type system
- Safe API Abstractions: Memory-safe wrappers around Docker Engine API
- Error Recovery: Structured error handling with automatic cleanup and rollback capabilities
🚀 Advanced Deployment Capabilities
- Intelligent Build Context: Automatic dependency tracking and efficient layer caching
- Variable Substitution: Advanced environment variable interpolation with fallback support
- Resource Management: Fine-grained control over CPU, memory, and network resources
- Health Monitoring: Sophisticated health check system with customizable probes
🔄 Docker Compose Integration
- Declarative & Programmatic: Use YAML configs or build service definitions in code
- Dependency Resolution: Automatic service ordering based on dependency graphs
- Network Isolation: Automatic network creation and service discovery
- Volume Management: Type-safe volume mounting with automatic cleanup
🛠 Developer Experience
- Async-first Design: Built on
tokiofor high-performance async I/O - Modular Architecture: Use only what you need with feature flags
- Comprehensive Logging: Detailed operation logging for debugging
- Testing Utilities: Rich testing infrastructure for container-based tests
Installation
Add to your Cargo.toml:
[]
# For parsing only (no deployment features)
= { = "0.1.0" }
# For full functionality including deployment (default)
= "0.1.0"
# Or explicitly with all features
= { = "0.1.0", = ["docker"] }
Usage
Feature Flags
parser- Enables Dockerfile and Docker Compose parsing functionality (minimal dependencies)deploy- Enables deployment features using Bollard (includes parser features)
Parser-Only Usage
use ;
// Parse a Dockerfile
let dockerfile_content = read_to_string?;
let config = parse?;
// Parse a Docker Compose file
let compose_content = read_to_string?;
let compose_config = parse?;
Full Deployment Usage
When the deploy feature is enabled:
use DockerBuilder;
async
Basic Dockerfile Deployment
use ;
async
Docker Compose Deployment
use ;
use HashMap;
async
Resource Management
use ;
let service = Service ;
Health Checks
use ;
let service = Service ;
Container Management
use DockerBuilder;
use HashMap;
async
Error Handling
The library provides detailed error types for proper error handling:
use DockerError;
match result
Development Status
This library is in active development. Current focus areas:
- Enhanced error handling with recovery strategies
- Comprehensive integration testing
- Additional Docker Compose features
- Improved resource management
- Better developer ergonomics
License
This project is licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your discretion.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request. When contributing:
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.