github.com/iqoqo/nomad@v0.11.3-0.20200911112621-d7021c74d101/website/pages/docs/drivers/raw_exec.mdx (about)

     1  ---
     2  layout: docs
     3  page_title: 'Drivers: Raw Exec'
     4  sidebar_title: Raw Fork/Exec
     5  description: The Raw Exec task driver simply fork/execs and provides no isolation.
     6  ---
     7  
     8  # Raw Fork/Exec Driver
     9  
    10  Name: `raw_exec`
    11  
    12  The `raw_exec` driver is used to execute a command for a task without any
    13  isolation. Further, the task is started as the same user as the Nomad process.
    14  As such, it should be used with extreme care and is disabled by default.
    15  
    16  ## Task Configuration
    17  
    18  ```hcl
    19  task "webservice" {
    20    driver = "raw_exec"
    21  
    22    config {
    23      command = "my-binary"
    24      args    = ["-flag", "1"]
    25    }
    26  }
    27  ```
    28  
    29  The `raw_exec` driver supports the following configuration in the job spec:
    30  
    31  - `command` - The command to execute. Must be provided. If executing a binary
    32    that exists on the host, the path must be absolute. If executing a binary that
    33    is downloaded from an [`artifact`](/docs/job-specification/artifact), the
    34    path can be relative from the allocation's root directory.
    35  
    36  - `args` - (Optional) A list of arguments to the `command`. References
    37    to environment variables or any [interpretable Nomad
    38    variables](/docs/runtime/interpolation) will be interpreted before
    39    launching the task.
    40  
    41  ## Examples
    42  
    43  To run a binary present on the Node:
    44  
    45  ```
    46  task "example" {
    47    driver = "raw_exec"
    48  
    49    config {
    50      # When running a binary that exists on the host, the path must be absolute/
    51      command = "/bin/sleep"
    52      args    = ["1"]
    53    }
    54  }
    55  ```
    56  
    57  To execute a binary downloaded from an [`artifact`](/docs/job-specification/artifact):
    58  
    59  ```
    60  task "example" {
    61    driver = "raw_exec"
    62  
    63    config {
    64      command = "name-of-my-binary"
    65    }
    66  
    67    artifact {
    68      source = "https://internal.file.server/name-of-my-binary"
    69      options {
    70        checksum = "sha256:abd123445ds4555555555"
    71      }
    72    }
    73  }
    74  ```
    75  
    76  ## Client Requirements
    77  
    78  The `raw_exec` driver can run on all supported operating systems. For security
    79  reasons, it is disabled by default. To enable raw exec, the Nomad client
    80  configuration must explicitly enable the `raw_exec` driver in the plugin's options:
    81  
    82  ```
    83  plugin "raw_exec" {
    84    config {
    85      enabled = true
    86    }
    87  }
    88  ```
    89  
    90  Nomad versions before v0.9 use the following client configuration. This configuration is
    91  also supported in Nomad v0.9.0, but is deprecated in favor of the plugin stanza:
    92  
    93  ```
    94  client {
    95    options = {
    96      "driver.raw_exec.enable" = "1"
    97    }
    98  }
    99  ```
   100  
   101  ## Plugin Options
   102  
   103  - `enabled` - Specifies whether the driver should be enabled or disabled.
   104    Defaults to `false`.
   105  
   106  - `no_cgroups` - Specifies whether the driver should not use
   107    cgroups to manage the process group launched by the driver. By default,
   108    cgroups are used to manage the process tree to ensure full cleanup of all
   109    processes started by the task. The driver uses cgroups by default on
   110    Linux and when `/sys/fs/cgroup/freezer/nomad` is writable for the
   111    Nomad process. Using a cgroup significantly reduces Nomad's CPU
   112    usage when collecting process metrics.
   113  
   114  ## Client Options
   115  
   116  ~> Note: client configuration options will soon be deprecated. Please use
   117  [plugin options][plugin-options] instead. See the [plugin stanza][plugin-stanza] documentation for more information.
   118  
   119  - `driver.raw_exec.enable` - Specifies whether the driver should be enabled or
   120    disabled. Defaults to `false`.
   121  
   122  - `driver.raw_exec.no_cgroups` - Specifies whether the driver should not use
   123    cgroups to manage the process group launched by the driver. By default,
   124    cgroups are used to manage the process tree to ensure full cleanup of all
   125    processes started by the task. The driver only uses cgroups when Nomad is
   126    launched as root, on Linux and when cgroups are detected.
   127  
   128  ## Client Attributes
   129  
   130  The `raw_exec` driver will set the following client attributes:
   131  
   132  - `driver.raw_exec` - This will be set to "1", indicating the driver is available.
   133  
   134  ## Resource Isolation
   135  
   136  The `raw_exec` driver provides no isolation.
   137  
   138  If the launched process creates a new process group, it is possible that Nomad
   139  will leak processes on shutdown unless the application forwards signals
   140  properly. Nomad will not leak any processes if cgroups are being used to manage
   141  the process tree. Cgroups are used on Linux when Nomad is being run with
   142  appropriate privileges, the cgroup system is mounted and the operator hasn't
   143  disabled cgroups for the driver.
   144  
   145  [plugin-options]: #plugin-options
   146  [plugin-stanza]: /docs/configuration/plugin