const CLONE_NEWUTS … const CLONE_NEWIPC … const CLONE_NEWUSER … const CLONE_NEWPID … const CLONE_NEWNET … const CLONE_IO … const bindMountPath … // Setns sets namespace using golang.org/x/sys/unix.Setns. // // Deprecated: Use golang.org/x/sys/unix.Setns instead. func Setns(ns NsHandle, nstype int) (err error) { … } // Set sets the current network namespace to the namespace represented // by NsHandle. func Set(ns NsHandle) (err error) { … } // New creates a new network namespace, sets it as current and returns // a handle to it. func New() (ns NsHandle, err error) { … } // NewNamed creates a new named network namespace, sets it as current, // and returns a handle to it func NewNamed(name string) (NsHandle, error) { … } // DeleteNamed deletes a named network namespace func DeleteNamed(name string) error { … } // Get gets a handle to the current threads network namespace. func Get() (NsHandle, error) { … } // GetFromPath gets a handle to a network namespace // identified by the path func GetFromPath(path string) (NsHandle, error) { … } // GetFromName gets a handle to a named network namespace such as one // created by `ip netns add`. func GetFromName(name string) (NsHandle, error) { … } // GetFromPid gets a handle to the network namespace of a given pid. func GetFromPid(pid int) (NsHandle, error) { … } // GetFromThread gets a handle to the network namespace of a given pid and tid. func GetFromThread(pid, tid int) (NsHandle, error) { … } // GetFromDocker gets a handle to the network namespace of a docker container. // Id is prefixed matched against the running docker containers, so a short // identifier can be used as long as it isn't ambiguous. func GetFromDocker(id string) (NsHandle, error) { … } // borrowed from docker/utils/utils.go func findCgroupMountpoint(cgroupType string) (int, string, error) { … } // Returns the relative path to the cgroup docker is running in. // borrowed from docker/utils/utils.go // modified to get the docker pid instead of using /proc/self func getDockerCgroup(cgroupVer int, cgroupType string) (string, error) { … } // Returns the first pid in a container. // borrowed from docker/utils/utils.go // modified to only return the first pid // modified to glob with id // modified to search for newer docker containers // modified to look for cgroups v2 func getPidForContainer(id string) (int, error) { … }