This is a Docker Remote API binding in Rust. Documentation is available here.
[dependencies]
docker = "0.0.37"
```rust extern crate docker;
use docker::Docker;
fn main() { let docker = match Docker::connect("unix:///var/run/docker.sock") { Ok(docker) => docker, Err(e) => { panic!("{}", e); } }; } ```
```rust extern crate docker;
use docker::Docker;
fn main() { let docker = match Docker::connect("unix:///var/run/docker.sock") { Ok(docker) => docker, Err(e) => { panic!("{}", e); } };
let containers = match docker.get_containers(false) {
Ok(containers) => containers,
Err(e) => { panic!("{}", e); }
};
} ```
```rust extern crate docker;
use docker::Docker;
fn main() { let docker = match Docker::connect("unix:///var/run/docker.sock") { Ok(docker) => docker, Err(e) => { panic!("{}", e); } };
let containers = match docker.get_containers(false) {
Ok(containers) => containers,
Err(e) => { panic!("{}", e); }
};
let stats = match docker.get_stats(&containers[0]) {
Ok(stats) => stats,
Err(e) => { panic!("{}", e); }
};
} ```
```rust extern crate docker;
use docker::Docker;
fn main() { let docker = match Docker::connect("unix:///var/run/docker.sock") { Ok(docker) => docker, Err(e) => { panic!("{}", e); } };
let images = match docker.get_images(false) {
Ok(images) => images,
Err(e) => { panic!({}, e); }
};
}
```
```rust extern crate docker;
use docker::Docker;
fn main() { let docker = match Docker::connect("unix:///var/run/docker.sock") { Ok(docker) => docker, Err(e) => { panic!("{}", e); } };
let info = match docker.get_system_info() {
Ok(info) => info,
Err(e) => { panic!("{}", e); }
};
} ```
```rust extern crate docker;
use docker::Docker;
fn main() { let docker = match Docker::connect("unix:///var/run/docker.sock") { Ok(docker) => docker, Err(e) => { panic!("{}", e); } };
let containers = match docker.get_containers(false) {
Ok(containers) => containers,
Err(e) => { panic!("{}", e); }
};
let processes = match docker.get_processes(&containers[0]) {
Ok(processes) => processes,
Err(e) => { panic!("{}", e); }
};
} ```
```rust extern crate docker;
use docker::Docker;
fn main() { let docker = match Docker::connect("unix:///var/run/docker.sock") { Ok(docker) => docker, Err(e) => { panic!("{}", e); } };
let containers = match docker.get_containers(false) {
Ok(containers) => containers,
Err(e) => { panic!("{}", e); }
};
let changes = match docker.get_filesystem_changes(&containers[0]) {
Ok(changes) => changes,
Err(e) => { panic!("{}", e); }
};
} ```
By default, Docker Toolbox
runs docker
with TLS enabled. It auto-generates certificates. The docker-machine
will copy them to ~/.docker/machine/certs
on the host machine once the VM has started.
```rust extern crate docker;
use docker::Docker; use std::path::Path;
fn main() {
let key = Path::new("/Users/
let mut docker = match Docker::connect("tcp://192.168.99.100:2376") {
Ok(docker) => docker,
Err(e) => { panic!("{}", e); }
};
docker.set_tls(&key, &cert, &ca).unwrap();
} ```
By default, boot2docker
runs docker
with TLS enabled. It auto-generates certificates and stores them in /home/docker/.docker
inside the VM. The boot2docker
up command will copy them to ~/.boot2docker/certs
on the host machine once the VM has started, and output the correct values for the DOCKER_CERT_PATH
and DOCKER_TLS_VERIFY
environment variables.
```rust extern crate docker;
use docker::Docker; use std::path::Path;
fn main() {
let key = Path::new("/Users/
let mut docker = match Docker::connect("tcp://192.168.59.103:2376") {
Ok(docker) => docker,
Err(e) => { panic!("{}", e); }
};
docker.set_tls(&key, &cert, &ca).unwrap();
} ```