Last active
August 29, 2015 14:04
Revisions
-
crosbymichael revised this gist
Oct 22, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,7 +11,7 @@ func startContainer() error { return err } factory, err := libcontainer.New("/var/lib/docker/execdrivers/libcontainer") if err != nil { return err } -
Michael Crosby revised this gist
Jul 17, 2014 . 1 changed file with 8 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -41,9 +41,16 @@ func startContainer() error { } // run another bash shell pid, exitCode, err := container.Start(process) if err != nil { return err } go func() { bashExitCode := <-exitCode log.Printf("bash exited with %d", bashExitCode) }() // freeze everything if err := container.Pause(); err != nil { -
Michael Crosby revised this gist
Jul 17, 2014 . 1 changed file with 6 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,11 +11,10 @@ func startContainer() error { return err } factory, err := libcontainer.New(config) if err != nil { return err } process := &libcontainer.Process{ Stdin: os.Stdin, @@ -29,9 +28,11 @@ func startContainer() error { }, } container, err := factory.Create("container-1", process) if err != nil { return err } defer container.Destroy() // container is now running pids, err := container.Processes() @@ -40,7 +41,7 @@ func startContainer() error { } // run another bash shell if err := container.Start(process); err != nil { return err } @@ -59,7 +60,7 @@ func startContainer() error { return err } if err := container.StartFunc(func() error { return syscall.Mknod(...) }); err != nil { return err -
Michael Crosby revised this gist
Jul 17, 2014 . 1 changed file with 6 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -58,5 +58,11 @@ func startContainer() error { if err != nil { return err } if err := container.ExecFunc(func() error { return syscall.Mknod(...) }); err != nil { return err } } -
Michael Crosby revised this gist
Jul 17, 2014 . 1 changed file with 54 additions and 44 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,47 +6,57 @@ import ( ) func startContainer() error { config, err := loadConfigFromSomewhere() if err != nil { return err } container, err := libcontainer.New(config) if err != nil { return err } defer container.Destroy() process := &libcontainer.Process{ Stdin: os.Stdin, Stdout: os.Stdout, Stderr: os.Stderr, Args: []string{ "/bin/bash", }, Env: []string{ "TERM=xterm", }, } if err := container.Exec(process); err != nil { return err } // container is now running pids, err := container.Processes() if err != nil { return err } // run another bash shell if err := container.Exec(process); err != nil { return err } // freeze everything if err := container.Pause(); err != nil { return err } // resume if err := container.Resume(); err != nil { return err } stats, err := container.Stats() if err != nil { return err } } -
Michael Crosby created this gist
Jul 17, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,52 @@ package main import ( "libcontainer" "os" ) func startContainer() error { config, err := loadConfigFromSomewhere() if err != nil { return err } container, err := libcontainer.New(config) if err != nil { return err } defer container.Destroy() process := &libcontainer.Process{ Stdin: os.Stdin, Stdout: os.Stdout, Stderr: os.Stderr, Args: []string{ "/bin/bash", }, Env: []string{ "TERM=xterm", }, } if err := container.Initialize(process); err != nil { return err } // container is now running pids, err := container.Processes() if err != nil { return err } // run another bash shell if err := container.Exec(process); err != nil { return err } // freeze everything if err := container.Pause(); err != nil { return err } }