...

Source file src/github.com/opencontainers/runc/create.go

Documentation: github.com/opencontainers/runc

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  	"os"
     6  
     7  	"github.com/urfave/cli"
     8  )
     9  
    10  var createCommand = cli.Command{
    11  	Name:  "create",
    12  	Usage: "create a container",
    13  	ArgsUsage: `<container-id>
    14  
    15  Where "<container-id>" is your name for the instance of the container that you
    16  are starting. The name you provide for the container instance must be unique on
    17  your host.`,
    18  	Description: `The create command creates an instance of a container for a bundle. The bundle
    19  is a directory with a specification file named "` + specConfig + `" and a root
    20  filesystem.
    21  
    22  The specification file includes an args parameter. The args parameter is used
    23  to specify command(s) that get run when the container is started. To change the
    24  command(s) that get executed on start, edit the args parameter of the spec. See
    25  "runc spec --help" for more explanation.`,
    26  	Flags: []cli.Flag{
    27  		cli.StringFlag{
    28  			Name:  "bundle, b",
    29  			Value: "",
    30  			Usage: `path to the root of the bundle directory, defaults to the current directory`,
    31  		},
    32  		cli.StringFlag{
    33  			Name:  "console-socket",
    34  			Value: "",
    35  			Usage: "path to an AF_UNIX socket which will receive a file descriptor referencing the master end of the console's pseudoterminal",
    36  		},
    37  		cli.StringFlag{
    38  			Name:  "pid-file",
    39  			Value: "",
    40  			Usage: "specify the file to write the process id to",
    41  		},
    42  		cli.BoolFlag{
    43  			Name:  "no-pivot",
    44  			Usage: "do not use pivot root to jail process inside rootfs.  This should be used whenever the rootfs is on top of a ramdisk",
    45  		},
    46  		cli.BoolFlag{
    47  			Name:  "no-new-keyring",
    48  			Usage: "do not create a new session keyring for the container.  This will cause the container to inherit the calling processes session key",
    49  		},
    50  		cli.IntFlag{
    51  			Name:  "preserve-fds",
    52  			Usage: "Pass N additional file descriptors to the container (stdio + $LISTEN_FDS + N in total)",
    53  		},
    54  	},
    55  	Action: func(context *cli.Context) error {
    56  		if err := checkArgs(context, 1, exactArgs); err != nil {
    57  			return err
    58  		}
    59  		status, err := startContainer(context, CT_ACT_CREATE, nil)
    60  		if err == nil {
    61  			// exit with the container's exit status so any external supervisor
    62  			// is notified of the exit with the correct exit status.
    63  			os.Exit(status)
    64  		}
    65  		return fmt.Errorf("runc create failed: %w", err)
    66  	},
    67  }
    68  

View as plain text