-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
42 lines (37 loc) · 814 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main
import (
"fmt"
"os"
"os/exec"
"syscall"
)
func main() {
syscall.Chroot("/home/containers/makeyourowncontainer/alpine-minirootfs-3.17.2-aarch64")
os.Chdir("/")
syscall.Mount("proc", "proc", "proc", 0, "")
cmd := exec.Command("/bin/busybox", "sh")
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stdout = os.Stderr
cmd.SysProcAttr = &syscall.SysProcAttr{
Cloneflags: syscall.CLONE_NEWUTS | syscall.CLONE_NEWUSER | syscall.CLONE_NEWNS | syscall.CLONE_NEWPID,
UidMappings: []syscall.SysProcIDMap{
{
ContainerID: 0,
HostID: 1000,
Size: 1,
},
},
GidMappings: []syscall.SysProcIDMap{
{
ContainerID: 0,
HostID: 1000,
Size: 1,
},
},
}
syscall.Unmount("proc", 0)
if err := cmd.Run(); err != nil {
fmt.Println(err)
}
}