added isolation feature for running containers

This commit is contained in:
2025-04-02 15:20:32 +02:00
parent d5bc0bbfc4
commit 5f6420a421
3 changed files with 31 additions and 4 deletions

View File

@@ -8,10 +8,26 @@ pub fn from(image: &str) -> Result<CommandResult, BuildahError> {
}
/// Run a command in a container
///
/// # Arguments
///
/// * `container` - The container ID or name
/// * `command` - The command to run
pub fn run(container: &str, command: &str) -> Result<CommandResult, BuildahError> {
execute_buildah_command(&["run", container, "sh", "-c", command])
}
/// Run a command in a container with specified isolation
///
/// # Arguments
///
/// * `container` - The container ID or name
/// * `command` - The command to run
/// * `isolation` - Isolation method (e.g., "chroot", "rootless", "oci")
pub fn run_with_isolation(container: &str, command: &str, isolation: &str) -> Result<CommandResult, BuildahError> {
execute_buildah_command(&["run", "--isolation", isolation, container, "sh", "-c", command])
}
/// Copy files into a container
pub fn copy(container: &str, source: &str, dest: &str) -> Result<CommandResult, BuildahError> {
execute_buildah_command(&["copy", container, source, dest])