docker-api-rs
docker-api-rs copied to clipboard
Missing Stop and Start example for Containers
I have been trying to add stop and start commands, but no luck so far. Can someone provide an example of how to do this?
There already is support for stopping and starting a container. Here is a short example:
use docker_api::Docker;
let docker = Docker::unix("/var/run/docker.sock");
let containers = docker.containers();
let container = containers.get("<container-id-or-name>");
container.start().await;
// ... Do something with the container ...
container.stop(None).await;
// The None here is an optional duration to wait for the container to close
I just noticed that this actions are missing from the example file https://github.com/vv9k/docker-api-rs/blob/master/examples/container.rs so it I'll rename this issue to track the addition of those actions to the file.