2015-06-22 10:31:12 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"github.com/Sirupsen/logrus"
|
|
|
|
"github.com/codegangsta/cli"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2015-07-03 00:59:30 +08:00
|
|
|
version = "0.2"
|
2015-08-08 21:32:30 +08:00
|
|
|
usage = `Open Container Initiative runtime
|
2015-06-26 07:26:31 +08:00
|
|
|
|
2015-08-08 21:32:30 +08:00
|
|
|
runc is a command line client for running applications packaged according to
|
|
|
|
the Open Container Format (OCF) and is a compliant implementation of the
|
|
|
|
Open Container Initiative specification.
|
2015-06-22 10:31:12 +08:00
|
|
|
|
2015-08-08 21:32:30 +08:00
|
|
|
runc integrates well with existing process supervisors to provide a production
|
|
|
|
container runtime environment for applications. It can be used with your
|
|
|
|
existing process monitoring tools and the container will be spawned as a
|
|
|
|
direct child of the process supervisor.
|
2015-06-22 10:31:12 +08:00
|
|
|
|
2015-08-08 21:32:30 +08:00
|
|
|
After creating a spec for your root filesystem with runc, you can execute a
|
|
|
|
container in your shell by running:
|
2015-06-22 10:31:12 +08:00
|
|
|
|
|
|
|
cd /mycontainer
|
2015-08-08 21:32:30 +08:00
|
|
|
runc [ spec-file ]
|
|
|
|
|
|
|
|
If not specified, the default value for the 'spec-file' is 'config.json'. `
|
2015-06-22 10:31:12 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
app := cli.NewApp()
|
|
|
|
app.Name = "runc"
|
|
|
|
app.Usage = usage
|
|
|
|
app.Version = version
|
|
|
|
app.Flags = []cli.Flag{
|
|
|
|
cli.StringFlag{
|
|
|
|
Name: "id",
|
|
|
|
Value: getDefaultID(),
|
|
|
|
Usage: "specify the ID to be used for the container",
|
|
|
|
},
|
|
|
|
cli.BoolFlag{
|
|
|
|
Name: "debug",
|
|
|
|
Usage: "enable debug output for logging",
|
|
|
|
},
|
|
|
|
cli.StringFlag{
|
|
|
|
Name: "root",
|
2015-07-29 01:47:22 +08:00
|
|
|
Value: "/run/oci",
|
2015-06-22 10:31:12 +08:00
|
|
|
Usage: "root directory for storage of container state (this should be located in tmpfs)",
|
|
|
|
},
|
|
|
|
cli.StringFlag{
|
|
|
|
Name: "criu",
|
|
|
|
Value: "criu",
|
|
|
|
Usage: "path to the criu binary used for checkpoint and restore",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
app.Commands = []cli.Command{
|
|
|
|
checkpointCommand,
|
|
|
|
eventsCommand,
|
|
|
|
restoreCommand,
|
2015-08-03 18:42:20 +08:00
|
|
|
killCommand,
|
2015-06-22 10:31:12 +08:00
|
|
|
specCommand,
|
|
|
|
}
|
|
|
|
app.Before = func(context *cli.Context) error {
|
|
|
|
if context.GlobalBool("debug") {
|
|
|
|
logrus.SetLevel(logrus.DebugLevel)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
2015-06-30 07:49:13 +08:00
|
|
|
|
|
|
|
app.Action = runAction
|
2015-06-25 02:14:46 +08:00
|
|
|
|
2015-06-22 10:31:12 +08:00
|
|
|
if err := app.Run(os.Args); err != nil {
|
|
|
|
logrus.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|