a rust interface for maneuvering docker containers
Find them 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, boot2docker typically
will have already set up every thing you need to get started.
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 mut docker = Docker.new(); let mut images = docker.images(); ```
rust
for i in images.list().unwrap() {
println!("-> {:?}", i);
}
rust
for i in image.search("rust").unwrap() {
println!("- {:?}", i);
}
todo
rust
let mut 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 mut docker = Docker.new(); let mut containers = docker.containers(); ```
rust
for c in contains.list().unwrap() {
println!("- {:?}", c);
}
rust
let mut 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