1 unstable release
0.1.0 | May 10, 2020 |
---|
#30 in #containers
61KB
1.5K
SLoC
Longshoreman
Usage
use longshoreman::{Docker, Result};
#[tokio::main]
async fn main() -> Result<()> {
let docker = Docker::new();
// Pull an image
docker.images().pull("ubuntu").tag("latest").send().await?;
// Create a container
let id = docker
.containers()
.create("ubuntu")
.name("my-container")
.send()
.await?
.id;
// Remove the container
docker
.containers()
.remove(id)
.force(true)
.send()
.await?;
Ok(())
}
Design
This little Docker client started life as an attempt to drag Shiplift up to date, but it grew arms and legs.
There's not many endpoints implemented just yet, but my aim is that as they're added, they are well-tested and strongly-typed.
it's early days, and i'm happy to accept notes of interest in particular endpoints, as well as pull requests.
- async/await support built on top of
std::future::Future
- pure Rust, sits on top of the battle-tested Hyper HTTP client
- builder API- only use the methods you need, less types to explicitly bring into scope.
Contributing
- Given the sheer number of endpoint which exist, and the number of options available for each, I'm absolutely depending on pull requests to help me tackle some of these
- the complicated logic of request handling is centralised, simplifying the implementation of the individual endpoints
- i'm unlikely to accept pull requests that do not have unit tests. Later, I would also like comprehensive integration tests for each endpoint. (this is tricky initially, because combinations of multiple endpoints will be required in order to create meaningful integration tests)
Dependencies
~14MB
~228K SLoC