Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/derekhjray/namespace
A namespace executor help library, used to execute task in specified linux namespaces
https://github.com/derekhjray/namespace
container namespace setns
Last synced: 2 days ago
JSON representation
A namespace executor help library, used to execute task in specified linux namespaces
- Host: GitHub
- URL: https://github.com/derekhjray/namespace
- Owner: derekhjray
- License: mit
- Created: 2022-06-06T03:27:07.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-07-28T07:06:02.000Z (over 1 year ago)
- Last Synced: 2024-11-09T05:07:36.892Z (about 2 months ago)
- Topics: container, namespace, setns
- Language: Go
- Homepage:
- Size: 32.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Namespace
A namespace executor help library, used to execute task in specified linux namespaces# Example
```go
package mainimport (
"bytes"
"log"
"os/exec"
"context"
"github.com/derekhjray/namespace"
)func ipLink(_ ...interface{}) error {
var (
stdout bytes.Buffer
)cmd := exec.CommandContext(context.TODO(), "ip", "link")
cmd.Stdout = &stdout
if err := cmd.Run(); err != nil {
return nil
}log.Println(stdout.String())
return nil
}func main() {
ns, err := namespace.New(namespace.Types(NET), namespace.Pid(2398))
if err != nil {
log.Println(err)
return
}err = ns.Execute(ipLink)
if err != nil {
log.Println(err)
return
}if err = ipLink(); err != nil {
log.Println(err)
}
}
```