Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/frontmage/docker_runner
docker runner
https://github.com/frontmage/docker_runner
Last synced: 30 days ago
JSON representation
docker runner
- Host: GitHub
- URL: https://github.com/frontmage/docker_runner
- Owner: FrontMage
- Created: 2022-04-13T04:40:39.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-10-17T01:29:37.000Z (about 2 years ago)
- Last Synced: 2024-03-14T22:21:32.813Z (10 months ago)
- Language: Rust
- Size: 20.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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());
```