-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain_command.go
More file actions
44 lines (40 loc) · 989 Bytes
/
Copy pathmain_command.go
File metadata and controls
44 lines (40 loc) · 989 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package main
import (
"fmt"
"mydocker/container"
log "github.com/sirupsen/logrus"
"github.com/urfave/cli"
)
var runCommand = cli.Command{
Name: "run",
Usage: `Create a container with namespace and cgroups limit
mydocker run -ti [command]`,
Flags: []cli.Flag{
cli.BoolFlag{
Name: "ti",
Usage: "enable tyy",
},
},
Action: func(context *cli.Context) error {
if len(context.Args()) < 1 {
return fmt.Errorf("Missing container command")
}
cmd := context.Args().Get(0)
tty := context.Bool("ti")
/*pass the command for running and -ti parameter*/
Run(tty, cmd)
return nil
},
}
var initCommand = cli.Command{
Name: "init",
Usage: "Init container process run user's process in container. Do not call it outside",
Action: func(context *cli.Context) error {
log.Infof("init come on")
cmd := context.Args().Get(0)
log.Infof("command %s", cmd)
/*Initialize the Container*/
err := container.RunContainerInitProcess(cmd, nil)
return err
},
}