A docker API wrapper library for rust.
docker.rs is currently under development, follow the below instructions to get started.
src/
and start hacking.docker_rs provides a rust interface to interact with Docker API. It is currently build to support latest version(1.37) of docker API. To get started make sure you have the docker daemon up.
rust
let client = match DockerClient::new("unix:///var/run/docker.sock") {
Ok(a) => a,
Err(err) => {
println!("{}", err);
exit(1);
}
};
```rust // Get version info for docker let info = client.getversioninfo();
// Get all containers(running/stopped) let allcontainers = client.listall_containers(None).unwrap();
// Get only running containers let runningcont = client.listrunning_containers(None).unwrap();
// Create a new container using an Image
let mut cmd: Vec
// Inspect the info for a container. let inspectinfo = client .inspectcontainer( "f808ca866b5fa80f65d6cd0937c72049272ea4c5aa4453e2abdd08d5efb59d3d", ) .unwrap();
// Get info regarding changes made to filesystem inside container let inspectinfo = client .getcontainerfilesystemchanges( "f808ca866b5fa80f65d6cd0937c72049272ea4c5aa4453e2abdd08d5efb59d3d", ) .unwrap();
// Start a created container let startinfo = client.startcontainer("f808ca...").unwrap();
// Kill a container let killinfo = client.killcontainer("f808ca...").unwrap(); ```
The library currently only provides unix socket interface support for communicating with docker daemon and is therefore fit for most purposes wherein the docker daemon you are interacting is local. To add an implementation of HTTP capable DockerClient look at the implementation of unix socket in /src/client.rs.
The only required method for implementing DockerApiClient
is request
wherein you make a request to the docker API
and returns the response. Once you have this you can implement each of api helpers like Containers
for your client
which uses this function itself.
This project is licensed under MIT License