added example for nerdctl + testing nerdctl (still a bug with running container from image)

This commit is contained in:
2025-04-02 17:21:39 +02:00
parent d6b53a72bb
commit 119d7ee50e
6 changed files with 316 additions and 3 deletions

View File

@@ -17,7 +17,8 @@ pub fn run_nerdctl_example() -> Result<(), NerdctlError> {
// Step 2: Create a container from the image
println!("\n=== Creating container from nginx:latest ===");
let run_result = nerdctl::run("nginx:latest", Some("my-nginx"), true, Some(&["8080:80"]))?;
// Use "native" snapshotter to avoid overlay mount issues
let run_result = nerdctl::run("nginx:latest", Some("my-nginx"), true, Some(&["8080:80"]), Some("native"))?;
println!("Container created: {}", run_result.stdout.trim());
let container_id = "my-nginx"; // Using the name we specified
@@ -47,7 +48,8 @@ pub fn run_nerdctl_example() -> Result<(), NerdctlError> {
// Step 7: Create a new container from our custom image
println!("\n=== Creating container from custom image ===");
nerdctl::run(image_name, Some("nginx-custom"), true, Some(&["8081:80"]))?;
// Use "native" snapshotter to avoid overlay mount issues
nerdctl::run(image_name, Some("nginx-custom"), true, Some(&["8081:80"]), Some("native"))?;
println!("Custom container created");
// Step 8: List images
@@ -78,5 +80,5 @@ pub fn run_all_examples() -> Result<(), NerdctlError> {
}
fn main() {
run_all_examples();
let _ = run_all_examples().unwrap();
}