github.com/blixtra/rkt@v0.8.1-0.20160204105720-ab0d1add1a43/Documentation/subcommands/run.md (about)

     1  # rkt run
     2  
     3  ## Image Addressing
     4  
     5  Images can be run by either their name, their hash, an explicit transport address, or a Docker registry URL.
     6  rkt will automatically [fetch](fetch.md) them if they're not present in the local store.
     7  
     8  ### Run By Name
     9  ```
    10  # rkt run coreos.com/etcd:v2.0.0
    11  ```
    12  
    13  ### Run By Hash
    14  ```
    15  # rkt run sha512-fa1cb92dc276b0f9bedf87981e61ecde
    16  ```
    17  
    18  ### Run By ACI Address
    19  ```
    20  # rkt run https://github.com/coreos/etcd/releases/download/v2.0.0/etcd-v2.0.0-linux-amd64.aci
    21  ```
    22  
    23  ### Run From a Docker Registry
    24  ```
    25  # rkt --insecure-options=image run docker://quay.io/coreos/etcd:v2.0.0
    26  ```
    27  
    28  ## Overriding Executable to launch
    29  
    30  Application images include an `exec` field that specifies the executable to launch.
    31  This executable can be overridden by rkt using the `--exec` flag:
    32  
    33  ```
    34  # rkt --insecure-options=image run docker://busybox --exec /bin/date
    35  ```
    36  
    37  ## Overriding Isolators
    38  
    39  Application images can include per-app isolators and some of them can be overridden by rkt.
    40  The units come from [the Kubernetes resource model](http://kubernetes.io/v1.1/docs/design/resources.html).
    41  In the following example, the CPU isolator is defined to 750 milli-cores and the memory isolator limits the memory usage to 128MB.
    42  
    43  ```
    44  # rkt run coreos.com/etcd:v2.0.0 --cpu=750m --memory=128M
    45  ```
    46  
    47  ## Passing Arguments
    48  
    49  To pass additional arguments to images use the pattern of `image1 -- [image1 flags] --- image2 -- [image2 flags]`.
    50  For example:
    51  
    52  ```
    53  # rkt run example.com/worker -- --loglevel verbose --- example.com/syncer -- --interval 30s
    54  ```
    55  
    56  This can be combined with overridden executables:
    57  
    58  ```
    59  # rkt run example.com/worker --exec /bin/ov -- --loglevel verbose --- example.com/syncer --exec /bin/syncer2 -- --interval 30s
    60  ```
    61  
    62  ## Influencing Environment Variables
    63  
    64  To inherit all environment variables from the parent use the `--inherit-env` flag.
    65  
    66  To explicitly set individual environment variables use the `--set-env` flag.
    67  
    68  The precedence is as follows with the last item replacing previous environment entries:
    69  
    70  - Parent environment
    71  - App image environment
    72  - Explicitly set environment
    73  
    74  ```
    75  # export EXAMPLE_ENV=hello
    76  # export EXAMPLE_OVERRIDE=under
    77  # rkt run --inherit-env --set-env=FOO=bar --set-env=EXAMPLE_OVERRIDE=over example.com/env-printer
    78  EXAMPLE_ENV=hello
    79  FOO=bar
    80  EXAMPLE_OVERRIDE=over
    81  ```
    82  
    83  ## Disable Signature Verification
    84  
    85  If desired, `--insecure-options=image` can be used to disable this security check:
    86  
    87  ```
    88  # rkt --insecure-options=image run coreos.com/etcd:v2.0.0
    89  rkt: searching for app image coreos.com/etcd:v2.0.0
    90  rkt: fetching image from https://github.com/coreos/etcd/releases/download/v2.0.0/etcd-v2.0.0-linux-amd64.aci
    91  rkt: warning: signature verification has been disabled
    92  ...
    93  ```
    94  
    95  ## Mount Volumes into a Pod
    96  
    97  Each ACI can define a [list of mount points](https://github.com/appc/spec/blob/master/spec/aci.md#image-manifest-schema) that the app is expecting external data to be mounted into:
    98  
    99  ```json
   100  {
   101      "acKind": "ImageManifest",
   102      "name": "example.com/app1",
   103      ...
   104      "app": {
   105          ...
   106          "mountPoints": [
   107              {
   108                  "name": "data",
   109                  "path": "/var/data",
   110                  "readOnly": false
   111              }
   112          ]
   113      }
   114      ...
   115  }
   116  ```
   117  
   118  To fulfill these mount points, volumes are used.
   119  A volume is assigned to a mount point if they both have the same name.
   120  There are today two kinds of volumes:
   121  
   122  - `host` volumes that can expose a directory or a file from the host to the pod.
   123  - `empty` volumes that initialize an empty storage to be accessed locally within the pod. When the pod is garbage collected, it will be removed.
   124  
   125  Each volume can be selectively mounted into each application at differing mount points.
   126  Note that any volumes that are specified but do not have a matching mount point (or [`--mount` flag](#mounting-volumes-without-mount-points)) will be silently ignored.
   127  
   128  If a mount point is specified in the image manifest but no matching volume is found, an implicit `empty` volume will be created automatically.
   129  
   130  ### Mounting Volumes
   131  
   132  Volumes are defined via the `--volume` flag, the volume is then mounted into each app running in the pod based on information defined in the ACI manifest.
   133  
   134  There are two kinds of volumes, `host` and `empty`.
   135  
   136  #### Host Volumes
   137  
   138  For `host` volumes, the `--volume` flag allows you to specify the volume name, the location on the host, and whether the volume is read-only or not.
   139  The volume name and location on the host are mandatory.
   140  The read-only parameter is false by default.
   141  
   142  Syntax:
   143  
   144  ```
   145  ---volume NAME,kind=host,source=SOURCE_PATH,readOnly=BOOL
   146  ```
   147  
   148  In the following example, we make the host's `/srv/data` accessible to app1 on `/var/data`:
   149  
   150  ```
   151  # rkt run --volume data,kind=host,source=/srv/data,readOnly=false example.com/app1
   152  ```
   153  
   154  If you don't intend to persist the data and you just want to have a volume shared between all the apps in the pod, you can use an `empty` volume:
   155  
   156  ```
   157  # rkt run --volume data,kind=empty,readOnly=false example.com/app1
   158  ```
   159  
   160  #### Empty Volumes
   161  
   162  For `empty` volumes, the `--volume` flag allows you to specify the volume name, and the mode, UID and GID of the generated volume.
   163  The volume name is mandatory.
   164  By default, `mode` is `0755`, UID is `0` and GID is `0`.
   165  
   166  Syntax:
   167  
   168   `--volume NAME,kind=empty,mode=MODE,uid=UID,gid=GID`
   169  
   170   In the following example, we create an empty volume for app1's `/var/data`:
   171  
   172   ```
   173   # rkt run --volume data,kind=empty,mode=0700,UID=0,GID=0
   174   ```
   175  
   176  ### Mounting Volumes without Mount Points
   177  
   178  If the ACI doesn't have any mount points defined in its manifest, you can still mount volumes using the `--mount` flag.
   179  
   180  With `--mount` you define a mapping between volumes and a path in the app.
   181  This will supplement and override any mount points in the image manifest.
   182  In the following example, the `--mount` option is positioned after the app name; it defines the mount only in that app:
   183  
   184  ```
   185  # rkt run --volume logs,kind=host,source=/srv/logs \
   186          example.com/app1 --mount volume=logs,target=/var/log \
   187          example.com/app2 --mount volume=logs,target=/opt/log
   188  ```
   189  
   190  In the following example, the `--mount` option is positioned before the app names.
   191  It defines mounts on all apps: both app1 and app2 will have `/srv/logs` accessible on `/var/log`.
   192  
   193  ```
   194  # rkt run --volume logs,kind=host,source=/srv/logs \
   195         --mount volume=data,target=/var/log \
   196          example.com/app1 example.com/app2
   197  ```
   198  
   199  ### MapReduce Example
   200  
   201  Let's say we want to read data from the host directory `/opt/tenant1/work` to power a MapReduce-style worker.
   202  We'll call this app `example.com/reduce-worker`.
   203  
   204  We also want this data to be available to a backup application that runs alongside the worker (in the same pod).
   205  We'll call this app 'example.com/worker-backup`.
   206  The backup application only needs read-only access to the data.
   207  
   208  Below we show the abbreviated manifests for the respective applications (recall that the manifest is bundled into the application's ACI):
   209  
   210  ```json
   211  {
   212      "acKind": "ImageManifest",
   213      "name": "example.com/reduce-worker",
   214      ...
   215      "app": {
   216          ...
   217          "mountPoints": [
   218              {
   219                  "name": "work",
   220                  "path": "/var/lib/work",
   221                  "readOnly": false
   222              }
   223          ],
   224          ...
   225      }
   226      ...
   227  }
   228  ```
   229  
   230  ```json
   231  {
   232      "acKind": "ImageManifest",
   233      "name": "example.com/worker-backup",
   234      ...
   235      "app": {
   236          ...
   237          "mountPoints": [
   238              {
   239                  "name": "work",
   240                  "path": "/backup",
   241                  "readOnly": true
   242              }
   243          ],
   244          ...
   245      }
   246      ...
   247  }
   248  ```
   249  
   250  In this case, both apps reference a volume they call "work", and expect it to be made available at `/var/lib/work` and `/backup` within their respective root filesystems.
   251  
   252  Since they reference the volume using an abstract name rather than a specific source path, the same image can be used on a variety of different hosts without being coupled to the host's filesystem layout.
   253  
   254  To tie it all together, we use the `rkt run` command-line to provide them with a volume by this name. Here's what it looks like:
   255  
   256  ```
   257  # rkt run --volume=work,kind=host,source=/opt/tenant1/work \
   258    example.com/reduce-worker \
   259    example.com/worker-backup
   260  ```
   261  
   262  If the image didn't have any mount points, you can achieve a similar effect with the `--mount` flag (note that both would be read-write though):
   263  
   264  ```
   265  # rkt run --volume=work,kind=host,source=/opt/tenant1/work \
   266    example.com/reduce-worker --mount volume=work,target=/var/lib/work \
   267    example.com/worker-backup --mount volume=work,target=/backup
   268  ```
   269  
   270  Now when the pod is running, the two apps will see the host's `/opt/tenant1/work` directory made available at their expected locations.
   271  
   272  ## Enabling metadata service registration
   273  
   274  By default, `rkt run` will not register the pod with the [metadata service](https://github.com/coreos/rkt/blob/master/Documentation/subcommands/metadata-service.md).
   275  You can enable registration with the `--mds-register` command line option.
   276  
   277  ## Pod Networking
   278  
   279  The `run` subcommand features the `--net` argument which takes options to configure the pod's network.
   280  
   281  ### Default contained networking
   282  
   283  When the argument is not given, `--net=default` is automatically assumed and the default contained network network will be loaded.
   284  
   285  ### Host networking
   286  
   287  Simplified, with `--net=host` the apps within the pod will share the network stack and the interfaces with the host machine.
   288  
   289  ```
   290  # rkt run --net=host coreos.com/etcd:v2.0.0
   291  ```
   292  
   293  Strictly seen, this is only true when `rkt run` is invoked on the host directly, because the network stack will be inherited from the process that is invoking the `rkt run` command.
   294  
   295  ### Other Networking Examples
   296  
   297  More details about rkt's networking options and examples can be found in the [networking documentation](https://github.com/coreos/rkt/blob/master/Documentation/networking.md)
   298  
   299  ## Run rkt as a Daemon
   300  
   301  rkt doesn't include any built-in support for running as a daemon.
   302  However, since it is a regular process, you can use your init system to achieve the same effect.
   303  
   304  For example, if you use systemd, you can [run rkt using `systemd-run`](https://github.com/coreos/rkt/blob/master/Documentation/using-rkt-with-systemd.md#systemd-run).
   305  
   306  If you don't use systemd, you can use [daemon](http://www.libslack.org/daemon/) as an alternative.
   307  
   308  ## Options
   309  
   310  | Flag | Default | Options | Description |
   311  | --- | --- | --- | --- |
   312  | `--cpu` |  `` | CPU units (example `--cpu=500m`, see the [Kubernetes resource model](http://kubernetes.io/v1.1/docs/design/resources.html)) | CPU limit for the preceding image |
   313  | `--dns` |  `` | IP Address | Name server to write in `/etc/resolv.conf`. It can be specified several times |
   314  | `--dns-opt` |  `` | Option as described in the options section in resolv.conf(5) | DNS option to write in `/etc/resolv.conf`. It can be specified several times |
   315  | `--dns-search` |  `` | Domain name | DNS search domain to write in `/etc/resolv.conf`. It can be specified several times |
   316  | `--exec` |  `` | A path | Override the exec command for the preceding image |
   317  | `--inherit-env` |  `false` | `true` or `false` | Inherit all environment variables not set by apps |
   318  | `--interactive` |  `false` | `true` or `false` | Run pod interactively. If true, only one image may be supplied |
   319  | `--mds-register` |  `false` | `true` or `false` | Register pod with metadata service. It needs network connectivity to the host (`--net=(default|default-restricted|host)` |
   320  | `--memory` |  `` | Memory units (example '--memory=50M', see the [Kubernetes resource model](http://kubernetes.io/v1.1/docs/design/resources.html)) | Memory limit for the preceding image |
   321  | `--mount` |  `` | Mount syntax (`volume=NAME,target=PATH`). See [Mounting Volumes without Mount Points](#mounting-volumes-without-mount-points) | Mount point binding a volume to a path within an app |
   322  | `--net` |  `default` | A comma-separated list of networks. Syntax: `--net[=n[:args], ...]` | Configure the pod's networking. Optionally, pass a list of user-configured networks to load and set arguments to pass to each network, respectively |
   323  | `--no-overlay` |  `false` | `true` or `false` | Disable overlay filesystem |
   324  | `--no-store` |  `false` | `true` or `false` | Fetch images, ignoring the local store. See [image fetching behavior](../image-fetching-behavior.md) |
   325  | `--pod-manifest` |  `` | A path | The path to the pod manifest. If it's non-empty, then only `--net`, `--no-overlay` and `--interactive` will have effect |
   326  | `--port` |  `` | A port number | Ports to expose on the host (requires [contained network](https://github.com/coreos/rkt/blob/master/Documentation/networking.md#contained-mode)). Syntax: --port=NAME:HOSTPORT |
   327  | `--private-users` |  `false` | `true` or `false` | Run within user namespaces (experimental) |
   328  | `--set-env` |  `` | An environment variable. Syntax `NAME=VALUE` | An environment variable to set for apps |
   329  | `--signature` |  `` | A file path | Local signature file to use in validating the preceding image |
   330  | `--stage1-url` |  `` | A URL to a stage1 image. HTTP/HTTPS/File/Docker URLs are supported | Image to use as stage1 |
   331  | `--stage1-path` |  `` | A path to a stage1 image. Absolute and relative paths are supported | Image to use as stage1 |
   332  | `--stage1-name` |  `` | A name of a stage1 image. Will perform a discovery if the image is not in the store | Image to use as stage1 |
   333  | `--stage1-hash` |  `` | A hash of a stage1 image. The image must exist in the store | Image to use as stage1 |
   334  | `--stage1-from-dir` |  `` | A stage1 image file inside the default stage1 images directory | Image to use as stage1 |
   335  | `--store-only` |  `false` | `true` or `false` | Use only available images in the store (do not discover or download from remote URLs). See [image fetching behavior](../image-fetching-behavior.md) |
   336  | `--uuid-file-save` |  `` | A file path | Write out the pod UUID to a file |
   337  | `--volume` |  `` | Volume syntax (`NAME,kind=KIND,source=PATH,readOnly=BOOL`). See [Mount Volumes into a Pod](#mount-volumes-into-a-pod) | Volumes to make available in the pod |
   338  
   339  ## Global options
   340  
   341  | Flag | Default | Options | Description |
   342  | --- | --- | --- | --- |
   343  | `--debug` |  `false` | `true` or `false` | Prints out more debug information to `stderr` |
   344  | `--dir` | `/var/lib/rkt` | A directory path | Path to the `rkt` data directory |
   345  | `--insecure-options` |  none | <ul><li>**none**: All security features are enabled</li><li>**http**: Allow HTTP connections. Be warned that this will send any credentials as clear text.</li><li>**image**: Disables verifying image signatures</li><li>**tls**: Accept any certificate from the server and any host name in that certificate</li><li>**ondisk**: Disables verifying the integrity of the on-disk, rendered image before running. This significantly speeds up start time.</li><li>**all**: Disables all security checks</li></ul>  | Comma-separated list of security features to disable |
   346  | `--local-config` |  `/etc/rkt` | A directory path | Path to the local configuration directory |
   347  | `--system-config` |  `/usr/lib/rkt` | A directory path | Path to the system configuration directory |
   348  | `--trust-keys-from-https` |  `false` | `true` or `false` | Automatically trust gpg keys fetched from https |
   349  | `--user-config` |  `` | A directory path | Path to the user configuration directory |