Created
February 20, 2019 07:48
-
-
Save jreisinger/65488e6d7648f3a07a1a346ae3ef549d to your computer and use it in GitHub Desktop.
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 characters
// run this as root on Linux - https://github.com/lizrice/containers-from-scratch/issues/1 | |
package main | |
import ( | |
"fmt" | |
"os" | |
"os/exec" | |
"syscall" | |
) | |
func main() { | |
switch os.Args[1] { | |
case "run": | |
run() | |
default: | |
panic("help") | |
} | |
} | |
func run() { | |
fmt.Printf("Running %v\n", os.Args[2:]) | |
cmd := exec.Command(os.Args[2], os.Args[3:]...) | |
cmd.Stdin = os.Stdin | |
cmd.Stderr = os.Stderr | |
cmd.Stdout = os.Stdout | |
// Create a namespace for hostname | |
cmd.SysProcAttr = &syscall.SysProcAttr{ | |
Cloneflags: syscall.CLONE_NEWUTS, | |
} | |
must(cmd.Run()) | |
} | |
func must(err error) { | |
if err != nil { | |
panic(err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment