Struct podman_api::api::Container [−][src]
pub struct Container<'podman> { /* fields omitted */ }
Expand description
Interface for accessing and manipulating Podman Container.
Implementations
Start this container.
Parameters:
- detach_keys - Override the key sequence for detaching a container. Format is a single character [a-Z] or ctrl- where is one of: a-z, @, ^, [, , or _.
Examples:
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
if let Err(e) = podman.containers().get("79c93f220e3e").start(None).await {
eprintln!("{}", e);
}
Stop this container.
Examples:
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
if let Err(e) = podman.containers().get("79c93f220e3e").stop(&Default::default()).await {
eprintln!("{}", e);
}
Return low-level information about this container.
Examples:
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
match podman.containers().get("79c93f220e3e").inspect().await {
Ok(info) => println!("{:?}", info),
Err(e) => eprintln!("{}", e);
}
Send a signal to this container.
Examples:
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
if let Err(e) = podman.containers().get("79c93f220e3e").send_signal("INT").await {
eprintln!("{}", e);
}
Kill this container.
Examples:
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
if let Err(e) = podman.containers().get("79c93f220e3e").kill().await {
eprintln!("{}", e);
}
Use the cgroups freezer to suspend all processes in this container.
Examples:
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
if let Err(e) = podman.containers().get("79c93f220e3e").pause().await {
eprintln!("{}", e);
}
Unpause this container
Examples:
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
if let Err(e) = podman.containers().get("79c93f220e3e").unpause().await {
eprintln!("{}", e);
}
Restart this container with a timeout.
Parameters:
- t - number of seconds to wait before killing the container
Examples:
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
if let Err(e) = podman.containers().get("79c93f220e3e").restart_with_timeout(20).await {
eprintln!("{}", e);
}
Restart this container.
Examples:
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
if let Err(e) = podman.containers().get("79c93f220e3e").restart().await {
eprintln!("{}", e);
}
Delete this container.
Examples:
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
if let Err(e) = podman
.containers()
.get("79c93f220e3e")
.delete(&ContainerDeleteOpts::builder().volumes(true).build())
.await
{
eprintln!("{}", e);
}
Force remove this container.
Examples:
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
if let Err(e) = podman.containers().get("79c93f220e3e").remove().await {
eprintln!("{}", e);
}
Mount this container to the filesystem.
Examples:
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
match podman.containers().get("79c93f220e3e").mount().await {
Ok(id) => println!("mounted container {}", id),
Err(e) => eprintln!("{}", e);
}
Unmount this container from the filesystem.
Examples:
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
if let Err(e) = podman.containers().get("79c93f220e3e").unmount().await {
eprintln!("{}", e);
}
pub async fn checkpoint(
&self,
opts: &ContainerCheckpointOpts
) -> impl Stream<Item = Result<Vec<u8>>> + 'podman
pub async fn checkpoint(
&self,
opts: &ContainerCheckpointOpts
) -> impl Stream<Item = Result<Vec<u8>>> + 'podman
Checkpoint this container.
Examples:
use futures_util::StreamExt;
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
let mut container_stream = podman.containers().get("79c93f220e3e").checkpoint(
&ContainerCheckpointOpts::builder()
.leave_running(true)
.print_stats(true)
.build(),
);
while let Some(chunk) = container_stream.next().await {
println!("{:?}", chunk);
}
Create a new image from this container.
Examples:
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
if let Err(e) = podman
.containers()
.get("79c93f220e3e")
.commit(
&ContainerCommitOpts::builder()
.pause(true)
.repo("image-name")
.tag("1.0.0")
.build(),
)
.await
{
eprintln!("{}", e);
}
Create an exec session to run a command inside this container. Exec sessions will be automatically removed 5 minutes after they exit.
This endpoint only creates the exec. To start it use Exec::start.
Examples:
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
let exec = podman
.containers()
.get("79c93f220e3e")
.create_exec(
&podman_api::opts::ExecCreateOpts::builder()
.command(["cat", "/some/path/in/container"])
.attach_stdout(true)
.attach_stderr(true)
.build(),
)
.await
.unwrap();
Change the name of this container.
Parameters:
- new_name - new name to give for this container
Examples:
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
if let Err(e) = podman.containers().get("79c93f220e3e").rename("my-container").await {
eprintln!("{}", e);
}
Performs all tasks necessary for initializing the container but does not start the container.
Examples:
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
if let Err(e) = podman.containers().get("79c93f220e3e").init().await {
eprintln!("{}", e);
}
Wait for this container to meet a given condition.
Examples:
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
if let Err(e) = podman
.containers()
.get("79c93f220e3e")
.wait(
&ContainerWaitOpts::builder()
.conditions([ContainerStatus::Configured])
.interval("300ms")
.build(),
)
.await
{
eprintln!("{}", e);
}
Quick way to determine if a container exists by name or ID
Examples:
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
match podman.containers().get("79c93f220e3e").exists().await {
Ok(exists) => if exists {
println!("container exists!");
} else {
println!("container doesn't exists!");
},
Err(e) => eprintln!("check failed: {}", e);
}
Trait Implementations
Auto Trait Implementations
impl<'podman> !RefUnwindSafe for Container<'podman>
impl<'podman> !UnwindSafe for Container<'podman>
Blanket Implementations
Mutably borrows from an owned value. Read more
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more