You've already forked runc
mirror of
https://github.com/opencontainers/runc.git
synced 2025-11-09 13:00:56 +03:00
Only define a single process
This removes the Processes slice and only allows for one process of the container. It also renames TTY to Terminal for a cross platform meaning. Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
32
README.md
32
README.md
@@ -43,22 +43,22 @@ user named `daemon` defined within that file-system.
|
|||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"version": "0.1",
|
"version": "0.1",
|
||||||
"os": "linux",
|
"platform": {
|
||||||
"arch": "amd64",
|
"os": "linux",
|
||||||
"processes": [
|
"arch": "amd64"
|
||||||
{
|
},
|
||||||
"tty": true,
|
"process": {
|
||||||
"user": "daemon",
|
"tty": true,
|
||||||
"args": [
|
"user": "daemon",
|
||||||
"sh"
|
"args": [
|
||||||
],
|
"sh"
|
||||||
"env": [
|
],
|
||||||
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
|
"env": [
|
||||||
"TERM=xterm"
|
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
|
||||||
],
|
"TERM=xterm"
|
||||||
"cwd": ""
|
],
|
||||||
}
|
"cwd": ""
|
||||||
],
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"path": "rootfs",
|
"path": "rootfs",
|
||||||
"readonly": true
|
"readonly": true
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ func restoreContainer(context *cli.Context, spec *Spec, config *configs.Config,
|
|||||||
Stdout: os.Stdout,
|
Stdout: os.Stdout,
|
||||||
Stderr: os.Stderr,
|
Stderr: os.Stderr,
|
||||||
}
|
}
|
||||||
tty, err := newTty(spec.Processes[0].TTY, process, rootuid)
|
tty, err := newTty(spec.Process.Terminal, process, rootuid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return -1, err
|
return -1, err
|
||||||
}
|
}
|
||||||
|
|||||||
7
run.go
7
run.go
@@ -10,9 +10,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func execContainer(context *cli.Context, spec *Spec) (int, error) {
|
func execContainer(context *cli.Context, spec *Spec) (int, error) {
|
||||||
if len(spec.Processes) != 1 {
|
|
||||||
return -1, fmt.Errorf("runc only supports one(1) process for the container")
|
|
||||||
}
|
|
||||||
config, err := createLibcontainerConfig(spec)
|
config, err := createLibcontainerConfig(spec)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return -1, err
|
return -1, err
|
||||||
@@ -38,8 +35,8 @@ func execContainer(context *cli.Context, spec *Spec) (int, error) {
|
|||||||
// ensure that the container is always removed if we were the process
|
// ensure that the container is always removed if we were the process
|
||||||
// that created it.
|
// that created it.
|
||||||
defer destroy(container)
|
defer destroy(container)
|
||||||
process := newProcess(spec.Processes[0])
|
process := newProcess(spec.Process)
|
||||||
tty, err := newTty(spec.Processes[0].TTY, process, rootuid)
|
tty, err := newTty(spec.Process.Terminal, process, rootuid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return -1, err
|
return -1, err
|
||||||
}
|
}
|
||||||
|
|||||||
42
spec.go
42
spec.go
@@ -18,11 +18,11 @@ type Mount struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Process struct {
|
type Process struct {
|
||||||
TTY bool `json:"tty"`
|
Terminal bool `json:"tty"`
|
||||||
User string `json:"user"`
|
User string `json:"user"`
|
||||||
Args []string `json:"args"`
|
Args []string `json:"args"`
|
||||||
Env []string `json:"env"`
|
Env []string `json:"env"`
|
||||||
Cwd string `json:"cwd"`
|
Cwd string `json:"cwd"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Root struct {
|
type Root struct {
|
||||||
@@ -41,12 +41,12 @@ type Platform struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type PortableSpec struct {
|
type PortableSpec struct {
|
||||||
Version string `json:"version"`
|
Version string `json:"version"`
|
||||||
Platform Platform `json:"platform"`
|
Platform Platform `json:"platform"`
|
||||||
Processes []*Process `json:"processes"`
|
Process Process `json:"process"`
|
||||||
Root Root `json:"root"`
|
Root Root `json:"root"`
|
||||||
Hostname string `json:"hostname"`
|
Hostname string `json:"hostname"`
|
||||||
Mounts []Mount `json:"mounts"`
|
Mounts []Mount `json:"mounts"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var specCommand = cli.Command{
|
var specCommand = cli.Command{
|
||||||
@@ -63,17 +63,15 @@ var specCommand = cli.Command{
|
|||||||
Path: "rootfs",
|
Path: "rootfs",
|
||||||
Readonly: true,
|
Readonly: true,
|
||||||
},
|
},
|
||||||
Processes: []*Process{
|
Process: Process{
|
||||||
{
|
Terminal: true,
|
||||||
TTY: true,
|
User: "daemon",
|
||||||
User: "daemon",
|
Args: []string{
|
||||||
Args: []string{
|
"sh",
|
||||||
"sh",
|
},
|
||||||
},
|
Env: []string{
|
||||||
Env: []string{
|
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
|
||||||
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
|
"TERM=xterm",
|
||||||
"TERM=xterm",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Hostname: "shell",
|
Hostname: "shell",
|
||||||
|
|||||||
2
utils.go
2
utils.go
@@ -160,7 +160,7 @@ func getDefaultImagePath(context *cli.Context) string {
|
|||||||
|
|
||||||
// newProcess returns a new libcontainer Process with the arguments from the
|
// newProcess returns a new libcontainer Process with the arguments from the
|
||||||
// spec and stdio from the current process.
|
// spec and stdio from the current process.
|
||||||
func newProcess(p *Process) *libcontainer.Process {
|
func newProcess(p Process) *libcontainer.Process {
|
||||||
return &libcontainer.Process{
|
return &libcontainer.Process{
|
||||||
Args: p.Args,
|
Args: p.Args,
|
||||||
Env: p.Env,
|
Env: p.Env,
|
||||||
|
|||||||
Reference in New Issue
Block a user