-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
58 lines (51 loc) · 1.05 KB
/
main.go
File metadata and controls
58 lines (51 loc) · 1.05 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package main
import (
"fmt"
"github.com/urfave/cli"
"log"
"os"
)
func main() {
app := cli.NewApp()
app.Name = "mydocker"
app.Usage = "just"
app.Commands = []cli.Command{
initCommand,
runCommand,
}
err := app.Run(os.Args)
if err != nil {
log.Fatal(err)
}
}
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 tty",
},
},
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")
//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.Println("init come on")
cmd := context.Args().Get(0)
log.Printf("command %s", cmd)
//err := container.RunContainerInitProcess(cmd, nil)
return err
},
}