Crates.io | docker-sync |
lib.rs | docker-sync |
version | 0.1.2 |
source | src |
created_at | 2021-06-14 17:17:56.700574 |
updated_at | 2021-10-05 10:32:54.069812 |
description | Minimalistic, synchronous, read-only client for local Docker socket |
homepage | https://github.com/bpetit/rs-docker-sync |
repository | https://github.com/bpetit/rs-docker-sync |
max_upload_size | |
id | 410013 |
size | 67,129 |
This is a fork
This is a fork of https://gitlab.com/kblobr/rust-docker (rs-docker on crate.io) which itself is a fork from https://github.com/ghmlee/rust-docker (docker on crates.io). Both repositories seemed to be no longer be maintained. The main reason for this fork, besides the maintainance, is that Scaphandre needed a synchronous library to talk to Docker socket.
Issues and PRs welcome.
Minimalistic, synchronous, read-only client for local Docker socket.
Documentation is available here.
[dependencies]
rs-docker-sync = "0.1.0"
extern crate docker_sync;
use docker_sync::Docker;
fn main() {
let docker = match Docker::connect() { // we consider the local Docker socket by default, with the default path (/var/run/docker.sock), no need to precise the path
Ok(docker) => docker,
Err(e) => { panic!("{}", e); }
};
}
extern crate docker_sync;
use docker_sync::Docker;
fn main() {
let mut docker = match Docker::connect() {
Ok(docker) => docker,
Err(e) => { panic!("{}", e); }
};
let networks = match docker.get_networks() {
Ok(networks) => networks,
Err(e) => { panic!("{}", e); }
};
}
extern crate docker_sync;
use docker_sync::Docker;
fn main() {
let mut docker = match Docker::connect() {
Ok(docker) => docker,
Err(e) => { panic!("{}", e); }
};
let containers = match docker.get_containers(false) {
Ok(containers) => containers,
Err(e) => { panic!("{}", e); }
};
}
extern crate docker_sync;
use docker_sync::Docker;
fn main() {
let mut docker = match Docker::connect() {
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); }
};
}
extern crate docker_sync;
use docker_sync::Docker;
fn main() {
let mut docker = match Docker::connect() {
Ok(docker) => docker,
Err(e) => { panic!("{}", e); }
};
let images = match docker.get_images(false) {
Ok(images) => images,
Err(e) => { panic!({}, e); }
};
}
extern crate docker_sync;
use docker_sync::Docker;
fn main() {
let mut docker = match Docker::connect() {
Ok(docker) => docker,
Err(e) => { panic!("{}", e); }
};
let info = match docker.get_system_info() {
Ok(info) => info,
Err(e) => { panic!("{}", e); }
};
}
extern crate docker_sync;
use docker_sync::Docker;
fn main() {
let mut docker = match Docker::connect() {
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); }
};
}
extern crate docker_sync;
use docker_sync::Docker;
fn main() {
let mut docker = match Docker::connect() {
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); }
};
}
extern crate docker_sync;
use docker_sync::Docker;
fn main() {
let mut docker = match Docker::connect() {
Ok(docker) => docker,
Err(e) => { panic!("{}", e); }
};
let containers = match docker.get_containers(false) {
Ok(containers) => containers,
Err(e) => { panic!("{}", e); }
};
let bytes = match docker.export_container(&containers[0]) {
Ok(bytes) => bytes,
Err(e) => { panic!("{}", e); }
};
}
extern crate docker_sync;
use docker_sync::Docker;
fn main() {
let mut docker = match Docker::connect() {
Ok(docker) => docker,
Err(e) => { panic!("{}", e); }
};
let ping = match docker.ping() {
Ok(ping) => ping,
Err(e) => { panic!("{}", e); }
};
}
extern crate docker_sync;
use docker_sync::Docker;
fn main() {
let mut docker = match Docker::connect() {
Ok(docker) => docker,
Err(e) => { panic!("{}", e); }
};
let version = match docker.get_version() {
Ok(version) => version,
Err(e) => {panic!("{}",e)}
};
}
To have a consistent dev environment one can use the docker image in /devenv like so:
git clone https://github.com/bpetit/rs-docker-sync
cd rust-docker/devenv
./build_docker
(this assumes your user can run docker commands, otherwise sudo
)./run_docker -ti
cd Code
cargo test