@@ -33,6 +33,9 @@ func main() {
3333 if err := sb .Terminate (context .Background ()); err != nil {
3434 log .Fatalf ("Failed to terminate Sandbox %s: %v" , sb .SandboxID , err )
3535 }
36+ if err := sb .Detach (); err != nil {
37+ log .Fatalf ("Failed to detach Sandbox %s: %v" , sb .SandboxID , err )
38+ }
3639 }()
3740
3841 _ , err = sb .Exec (ctx , []string {"mkdir" , "-p" , "/app/data" }, nil )
@@ -57,6 +60,9 @@ func main() {
5760 log .Fatalf ("Failed to terminate Sandbox %s: %v" , sb .SandboxID , err )
5861 }
5962 fmt .Println ("Terminated first Sandbox" )
63+ if err := sb .Detach (); err != nil {
64+ log .Fatalf ("Failed to detach Sandbox %s: %v" , sb .SandboxID , err )
65+ }
6066
6167 // Create new Sandbox from snapshot Image
6268 sb2 , err := mc .Sandboxes .Create (ctx , app , snapshotImage , nil )
@@ -69,6 +75,9 @@ func main() {
6975 if err := sb2 .Terminate (context .Background ()); err != nil {
7076 log .Fatalf ("Failed to terminate Sandbox %s: %v" , sb2 .SandboxID , err )
7177 }
78+ if err := sb2 .Detach (); err != nil {
79+ log .Fatalf ("Failed to detach Sandbox %s: %v" , sb .SandboxID , err )
80+ }
7281 }()
7382
7483 proc , err := sb2 .Exec (ctx , []string {"cat" , "/app/data/info.txt" }, nil )
0 commit comments