| "github.com/opencontainers/runc/libcontainer" |
| "github.com/opencontainers/runc/libcontainer/logs" |
| _ "github.com/opencontainers/runc/libcontainer/nsenter" |
| "github.com/sirupsen/logrus" |
| if len(os.Args) > 1 && os.Args[1] == "init" { |
| level := os.Getenv("_LIBCONTAINER_LOGLEVEL") |
| logLevel, err := logrus.ParseLevel(level) |
| panic(fmt.Sprintf("libcontainer: failed to parse log level: %q: %v", level, err)) |
| err = logs.ConfigureLogging(logs.Config{ |
| LogPipeFd: os.Getenv("_LIBCONTAINER_LOGPIPE"), |
| panic(fmt.Sprintf("libcontainer: failed to configure logging: %v", err)) |
| logrus.Debug("child process in init()") |
| var initCommand = cli.Command{ |
| Usage: `initialize the namespaces and launch the process (do not call it outside of runc)`, |
| Action: func(context *cli.Context) error { |
| factory, _ := libcontainer.New("") |
| if err := factory.StartInitialization(); err != nil { |
| // as the error is sent back to the parent there is no need to log |
| // or write it to stderr because the parent process will handle this |
| panic("libcontainer: container init failed to exec") |