隔離各個(gè)進(jìn)程的掛載點(diǎn)視圖.
mount namespace中進(jìn)行的mount,umount不會(huì)影響全局
運(yùn)行后mount -t proc proc /proc?
通過ps -ef 確認(rèn)
package main
import (
"log"
"os"
"os/exec"
"syscall"
)
func main() {
cmd := exec.Command("/bin/bash")
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Stdin = os.Stdin
cmd.SysProcAttr = &syscall.SysProcAttr{}
cmd.SysProcAttr.Cloneflags = syscall.CLONE_NEWNS | syscall.CLONE_NEWPID
if err := cmd.Run(); err != nil {
log.Fatal(err)
}
}