a rust interface for maneuvering docker containers
Add the following to your Cargo.toml
file
toml
[dependencies]
shiplift = "0.2"
Find them here.
Some small example programs can be found here.
To use shiplift you must first have a running docker daemon readily accessible. Typically this daemon
is reachable via url identified by an env named DOCKER_HOST
. If you are using osx, docker-machine typically
will have already set up every thing you need to get started when you run docker-machine env {envid}
.
rust
extern crate shiplift;
let docker = shiplift::Docker::new();
If you wish to be more explicit you can provide a host in the form of a url.Url
.
```rust extern crate shiplift; extern crate url;
use shiplift::Docker; use url::Url;
let docker = Docker::host(Url::parse("http://yourhost").unwrap()); ```
If you are interacting with docker containers, chances are you will also need to interact with docker image information. You can interact docker images with docker.images()
.
```rust extern crate shiplift;
use shiplift::Docker;
let docker = Docker.new(); let images = docker.images(); ```
rust
for i in images.list(&Default::default()).unwrap() {
println!("-> {:?}", i);
}
rust
for i in image.search("rust").unwrap() {
println!("- {:?}", i);
}
todo
rust
let img = images.get("imagename");
rust
println!("- {:?}", img.inspect().unwrap());
rust
for h in img.history().unwrap() {
println!("- {:?}", h);
}
rust
println!("- {:?}", img.delete().unwrap());
Containers are instances of images. To gain access to this interface use docker.containers()
```rust extern crate shiplift;
use shiplift::Docker;
let docker = Docker.new(); let containers = docker.containers(); ```
rust
for c in containers.list(&Default::default()).unwrap() {
println!("- {:?}", c);
}
rust
let container = containers.get("containerid");
rust
println!("- {:?}", container.inspect());
top
inforust
println!("- {:?}", container.top().unwrap());
(todoc)
rust
for c in container.changes().unwrap() {
println!("- {:?}", c);
}
rust
for stats in container.stats().unwrap() {
println!("- {:?}", stats);
}
rust
container.stop();
container.start();
container.restart();
todoc
Doug Tangren (softprops) 2015