github.com/zhuohuang-hust/src-cbuild@v0.0.0-20230105071821-c7aab3e7c840/mergeCode/runc/man/runc-spec.8.md (about)

     1  # NAME
     2     runc spec - create a new specification file
     3  
     4  # SYNOPSIS
     5     runc spec [command options] [arguments...]
     6  
     7  # DESCRIPTION
     8     The spec command creates the new specification file named "config.json" for
     9  the bundle.
    10  
    11  The spec generated is just a starter file. Editing of the spec is required to
    12  achieve desired results. For example, the newly generated spec includes an args
    13  parameter that is initially set to call the "sh" command when the container is
    14  started. Calling "sh" may work for an ubuntu container or busybox, but will not
    15  work for containers that do not include the "sh" program.
    16  
    17  # EXAMPLE
    18    To run docker's hello-world container one needs to set the args parameter
    19  in the spec to call hello. This can be done using the sed command or a text
    20  editor. The following commands create a bundle for hello-world, change the
    21  default args parameter in the spec from "sh" to "/hello", then run the hello
    22  command in a new hello-world container named container1:
    23  
    24      mkdir hello
    25      cd hello
    26      docker pull hello-world
    27      docker export $(docker create hello-world) > hello-world.tar
    28      mkdir rootfs
    29      tar -C rootfs -xf hello-world.tar
    30      runc spec
    31      sed -i 's;"sh";"/hello";' config.json
    32      runc start container1
    33  
    34  In the start command above, "container1" is the name for the instance of the
    35  container that you are starting. The name you provide for the container instance
    36  must be unique on your host.
    37  
    38  An alternative for generating a customized spec config is to use "ocitools", the
    39  sub-command "ocitools generate" has lots of options that can be used to do any
    40  customizations as you want, see [ocitools](https://github.com/opencontainers/ocitools)
    41  to get more information.
    42  
    43  When starting a container through runc, runc needs root privilege. If not
    44  already running as root, you can use sudo to give runc root privilege. For
    45  example: "sudo runc start container1" will give runc root privilege to start the
    46  container on your host.
    47  
    48  # OPTIONS
    49     --bundle value, -b value     path to the root of the bundle directory