#Docker-Rust (WIP)
A client library for the Docker Remote API written in Rust.
Currently targetting API v1.12+
A lot of functionality is currently on hold until Rust's HTTP and JSON libs are up to snuff.
make test
Declare cargo dependency in your Cargo.toml
[dependencies.docker]
git = "https://github.com/abh1nav/docker-rust.git"
extern crate docker;
use docker::Docker;
// Currently only works if docker is run using a unix socket (the default)
let client: Docker = Docker {
socket_path: "/var/run/docker.sock"
};
// common::containers::Containers is a Vec<common::containers::Container>
let containers: Containers = client.get_containers();
println!("Running container count: {}", containers.len());
let container_id = "5fc6a1226f01".to_string();
// Restart container
client.restart_container(container_id.as_slice());
// OR wait 3 seconds for the container to stop before forcing restart
client.restart_container_with_timeout(container_id.as_slice(), 3);
// Stop the container
client.stop_container(container_id.as_slice());
// OR wait 3 seconds for the container to stop before killing
client.stop_container_with_timeout(container_id.as_slice(), 3);
// Remove the container and its volumes
client.remove_container(container_id.as_slice());
// OR remove with the force flag
client.remove_container_with_force(container_id.as_slice());
// common::images::Images is a Vec<common::images::Image>
let images: Images = client.get_images();
println!("Image count: {}", images.len());
// Get system info -> common::sys_info::SysInfo
let sys_info = client.get_sys_info();
println!("Number of containers: {}\nNumber of Images: {}", sys_info.Containers, sys_info.Images);
// Get docker version -> common::version::Version
let version = client.get_version();
println!("Docker version: {}", version.Version);