Skip to content

Instantly share code, notes, and snippets.

@jreisinger
Created February 20, 2019 07:48
Show Gist options
  • Save jreisinger/65488e6d7648f3a07a1a346ae3ef549d to your computer and use it in GitHub Desktop.
Save jreisinger/65488e6d7648f3a07a1a346ae3ef549d to your computer and use it in GitHub Desktop.
// 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