Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/frontmage/docker_runner

docker runner
https://github.com/frontmage/docker_runner

Last synced: 30 days ago
JSON representation

docker runner

Awesome Lists containing this project

README

        

# docker_runner

usage

```rust
use docker_runner::{Docker, DockerRunner};
use std::time::Duration;
let docker = Docker::connect_with_socket_defaults().unwrap();
// change the max_container_running_time to desire value
let dr = DockerRunner::new(docker, 1, "runner_container".into(), "yes".into(), 10);
// call this to free images
dr.clear_images_by_whitelist().await.unwrap();
dr.run("busybox:latest", vec!["sleep", "100"])
.await
.unwrap();
dr.run("busybox:latest", vec!["sleep", "100"])
.await
.unwrap();
dr.run("busybox:latest", vec!["sleep", "100"])
.await
.unwrap();
assert_eq!(3, dr.list_runner_containers().await.unwrap().len());
tokio::time::sleep(Duration::from_secs(3)).await;
// call this to free containers
dr.clear_timeout_containers().await.unwrap();
assert_eq!(0, dr.list_runner_containers().await.unwrap().len());
```