shiplift
a rust interface for maneuvering docker containers
install
Add the following to your Cargo.toml
file
[]
= "0.3"
docs
Find them here.
usage
Some small example programs can be found in this repository's examples directory.
communicating with hosts
To use shiplift, you must first have a docker daemon readily accessible. Typically this daemon processs
is resolvable via a url specified by an env var 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}
.
extern crate shiplift;
let docker = new;
If you wish to be more explicit you can provide a host in the form of a url.Url
.
extern crate shiplift;
extern crate url;
use Docker;
use Url;
let docker = host;
images
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()
.
extern crate shiplift;
use Docker;
let docker = Docker.new;
let images = docker.images;
list host-local images
for i in images.list.unwrap
find remote images
for i in image.search.unwrap
creating new image by pulling an existing image
use PullOptions;
let output = images.pull.unwrap;
for o in output
build an image from the contents of a directory containing a Dockerfile
the following is equivalent to docker build -t shiplift_test .
use BuildOptions;
let output = images.build.unwrap;
for o in output
accessing image info
let img = images.get;
inspecting image info
println!;
getting image history
for h in img.history.unwrap
deleting image
println!;
containers
Containers are instances of images. To gain access to this interface use docker.containers()
extern crate shiplift;
use Docker;
let docker = Docker.new;
let containers = docker.containers;
listing host local containers
for c in containers.list.unwrap
get a container reference
let container = containers.get;
inspect container details
println!;
access top
info
println!;
view container logs
(todoc)
view a list of container changes
for c in container.changes.unwrap
stream container stats
for stats in container.stats.unwrap
stop, start, restart container
container.stop;
container.start;
container.restart;
misc
todoc
roadmap
There are plans on switching from rustc-serialize to serde for serialization in 0.4.0 this should not have major impact on current interfaces.
Doug Tangren (softprops) 2015-2016