mirror of
https://github.com/criyle/go-sandbox.git
synced 2025-11-04 14:49:53 +08:00
update documentations
This commit is contained in:
parent
33a7b2b603
commit
5b50e9db4d
27
README.md
27
README.md
@ -122,6 +122,33 @@ Container / Host Communication Protocol (single thread):
|
||||
|
||||
Any socket related error will cause the container exit (with all process inside container)
|
||||
|
||||
### Pre-forked Container Environment
|
||||
|
||||
Container restricted environment is accessed though RPC interface defined by above protocol
|
||||
|
||||
Provides:
|
||||
|
||||
- File access
|
||||
- Open: create / access files
|
||||
- Delete: remove file
|
||||
- Management
|
||||
- Ping: alive check
|
||||
- Reset: remove temporary files
|
||||
- Destroy: destroy the container environment
|
||||
- Run program
|
||||
- Execve: execute program with given parameters
|
||||
|
||||
``` go
|
||||
type Environment interface {
|
||||
Ping() error
|
||||
Open([]OpenCmd) ([]*os.File, error)
|
||||
Delete(p string) error
|
||||
Reset() error
|
||||
Execve(context.Context, ExecveParam) <-chan types.Result
|
||||
Destroy() error
|
||||
}
|
||||
```
|
||||
|
||||
## Packages (/pkg)
|
||||
|
||||
- seccomp: provides seccomp type definition
|
||||
|
||||
@ -45,7 +45,7 @@ func Init() (err error) {
|
||||
// limit container resource usage
|
||||
runtime.GOMAXPROCS(containerMaxProc)
|
||||
|
||||
// new_master shared the socket at fd 3 (marked close_exec)
|
||||
// new_container environment shared the socket at fd 3 (marked close_exec)
|
||||
const defaultFd = 3
|
||||
soc, err := unixsocket.NewSocket(defaultFd)
|
||||
if err != nil {
|
||||
|
||||
@ -56,7 +56,7 @@ type Environment interface {
|
||||
// container manages single pre-forked container environment
|
||||
type container struct {
|
||||
pid int // underlying container init pid
|
||||
socket *unixsocket.Socket // master - container communication
|
||||
socket *unixsocket.Socket // host - container communication
|
||||
mu sync.Mutex // lock to avoid race condition
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user