2015-10-08 19:18:44 +00:00
|
|
|
---
|
2020-02-06 23:45:31 +00:00
|
|
|
layout: docs
|
|
|
|
page_title: 'Drivers: Raw Exec'
|
|
|
|
sidebar_title: Raw Fork/Exec
|
|
|
|
description: The Raw Exec task driver simply fork/execs and provides no isolation.
|
2015-10-08 19:18:44 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
# Raw Fork/Exec Driver
|
|
|
|
|
|
|
|
Name: `raw_exec`
|
|
|
|
|
|
|
|
The `raw_exec` driver is used to execute a command for a task without any
|
2015-10-09 18:29:59 +00:00
|
|
|
isolation. Further, the task is started as the same user as the Nomad process.
|
|
|
|
As such, it should be used with extreme care and is disabled by default.
|
2015-10-08 19:18:44 +00:00
|
|
|
|
|
|
|
## Task Configuration
|
|
|
|
|
2016-10-03 21:35:20 +00:00
|
|
|
```hcl
|
|
|
|
task "webservice" {
|
|
|
|
driver = "raw_exec"
|
|
|
|
|
|
|
|
config {
|
|
|
|
command = "my-binary"
|
|
|
|
args = ["-flag", "1"]
|
|
|
|
}
|
2020-02-06 23:45:31 +00:00
|
|
|
}
|
2016-10-03 21:35:20 +00:00
|
|
|
```
|
|
|
|
|
2015-10-08 19:18:44 +00:00
|
|
|
The `raw_exec` driver supports the following configuration in the job spec:
|
|
|
|
|
2020-02-06 23:45:31 +00:00
|
|
|
- `command` - The command to execute. Must be provided. If executing a binary
|
2016-03-16 16:56:04 +00:00
|
|
|
that exists on the host, the path must be absolute. If executing a binary that
|
2020-02-06 23:45:31 +00:00
|
|
|
is downloaded from an [`artifact`](/docs/job-specification/artifact), the
|
2019-01-29 20:53:05 +00:00
|
|
|
path can be relative from the allocation's root directory.
|
2015-11-18 23:16:42 +00:00
|
|
|
|
2020-02-06 23:45:31 +00:00
|
|
|
- `args` - (Optional) A list of arguments to the `command`. References
|
2016-10-03 21:35:20 +00:00
|
|
|
to environment variables or any [interpretable Nomad
|
2020-02-06 23:45:31 +00:00
|
|
|
variables](/docs/runtime/interpolation) will be interpreted before
|
2016-10-11 19:52:50 +00:00
|
|
|
launching the task.
|
2015-10-08 19:18:44 +00:00
|
|
|
|
2016-03-16 16:56:04 +00:00
|
|
|
## Examples
|
2015-10-08 19:18:44 +00:00
|
|
|
|
2016-03-16 16:56:04 +00:00
|
|
|
To run a binary present on the Node:
|
2015-10-08 19:18:44 +00:00
|
|
|
|
|
|
|
```
|
2016-10-03 21:35:20 +00:00
|
|
|
task "example" {
|
|
|
|
driver = "raw_exec"
|
2016-03-16 16:56:04 +00:00
|
|
|
|
2016-10-03 21:35:20 +00:00
|
|
|
config {
|
|
|
|
# When running a binary that exists on the host, the path must be absolute/
|
|
|
|
command = "/bin/sleep"
|
|
|
|
args = ["1"]
|
2015-11-21 20:18:16 +00:00
|
|
|
}
|
2016-10-03 21:35:20 +00:00
|
|
|
}
|
2015-10-08 19:18:44 +00:00
|
|
|
```
|
|
|
|
|
2020-02-06 23:45:31 +00:00
|
|
|
To execute a binary downloaded from an [`artifact`](/docs/job-specification/artifact):
|
2015-10-15 21:40:08 +00:00
|
|
|
|
2016-03-16 16:56:04 +00:00
|
|
|
```
|
2016-10-03 21:35:20 +00:00
|
|
|
task "example" {
|
|
|
|
driver = "raw_exec"
|
2015-10-15 21:40:08 +00:00
|
|
|
|
2016-10-03 21:35:20 +00:00
|
|
|
config {
|
|
|
|
command = "name-of-my-binary"
|
|
|
|
}
|
2015-10-15 21:40:08 +00:00
|
|
|
|
2016-10-03 21:35:20 +00:00
|
|
|
artifact {
|
|
|
|
source = "https://internal.file.server/name-of-my-binary"
|
|
|
|
options {
|
|
|
|
checksum = "sha256:abd123445ds4555555555"
|
2016-03-16 16:56:04 +00:00
|
|
|
}
|
2015-10-15 21:40:08 +00:00
|
|
|
}
|
2016-10-03 21:35:20 +00:00
|
|
|
}
|
2015-10-15 21:40:08 +00:00
|
|
|
```
|
|
|
|
|
2016-03-16 16:56:04 +00:00
|
|
|
## Client Requirements
|
|
|
|
|
2016-10-03 21:35:20 +00:00
|
|
|
The `raw_exec` driver can run on all supported operating systems. For security
|
|
|
|
reasons, it is disabled by default. To enable raw exec, the Nomad client
|
2019-01-29 20:53:05 +00:00
|
|
|
configuration must explicitly enable the `raw_exec` driver in the plugin's options:
|
|
|
|
|
|
|
|
```
|
|
|
|
plugin "raw_exec" {
|
|
|
|
config {
|
|
|
|
enabled = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2019-03-07 01:24:01 +00:00
|
|
|
Nomad versions before v0.9 use the following client configuration. This configuration is
|
2019-03-06 16:07:54 +00:00
|
|
|
also supported in Nomad v0.9.0, but is deprecated in favor of the plugin stanza:
|
2015-10-15 21:40:08 +00:00
|
|
|
|
|
|
|
```
|
2016-10-03 21:35:20 +00:00
|
|
|
client {
|
|
|
|
options = {
|
|
|
|
"driver.raw_exec.enable" = "1"
|
|
|
|
}
|
|
|
|
}
|
2015-10-15 21:40:08 +00:00
|
|
|
```
|
|
|
|
|
2019-01-29 20:53:05 +00:00
|
|
|
## Plugin Options
|
|
|
|
|
2020-02-06 23:45:31 +00:00
|
|
|
- `enabled` - Specifies whether the driver should be enabled or disabled.
|
2019-01-29 20:53:05 +00:00
|
|
|
Defaults to `false`.
|
|
|
|
|
2020-02-06 23:45:31 +00:00
|
|
|
- `no_cgroups` - Specifies whether the driver should not use
|
2019-01-29 20:53:05 +00:00
|
|
|
cgroups to manage the process group launched by the driver. By default,
|
|
|
|
cgroups are used to manage the process tree to ensure full cleanup of all
|
2019-07-24 15:57:52 +00:00
|
|
|
processes started by the task. The driver uses cgroups by default on
|
|
|
|
Linux and when `/sys/fs/cgroup/freezer/nomad` is writable for the
|
|
|
|
Nomad process. Using a cgroup significantly reduces Nomad's CPU
|
|
|
|
usage when collecting process metrics.
|
2019-01-29 20:53:05 +00:00
|
|
|
|
2018-05-30 17:02:30 +00:00
|
|
|
## Client Options
|
|
|
|
|
2020-02-06 23:45:31 +00:00
|
|
|
~> Note: client configuration options will soon be deprecated. Please use
|
2019-01-29 20:53:05 +00:00
|
|
|
[plugin options][plugin-options] instead. See the [plugin stanza][plugin-stanza] documentation for more information.
|
|
|
|
|
2020-02-06 23:45:31 +00:00
|
|
|
- `driver.raw_exec.enable` - Specifies whether the driver should be enabled or
|
2019-01-29 20:53:05 +00:00
|
|
|
disabled. Defaults to `false`.
|
2018-05-30 17:02:30 +00:00
|
|
|
|
2020-02-06 23:45:31 +00:00
|
|
|
- `driver.raw_exec.no_cgroups` - Specifies whether the driver should not use
|
2018-05-30 17:02:30 +00:00
|
|
|
cgroups to manage the process group launched by the driver. By default,
|
|
|
|
cgroups are used to manage the process tree to ensure full cleanup of all
|
|
|
|
processes started by the task. The driver only uses cgroups when Nomad is
|
|
|
|
launched as root, on Linux and when cgroups are detected.
|
|
|
|
|
2015-10-08 19:18:44 +00:00
|
|
|
## Client Attributes
|
|
|
|
|
|
|
|
The `raw_exec` driver will set the following client attributes:
|
|
|
|
|
2020-02-06 23:45:31 +00:00
|
|
|
- `driver.raw_exec` - This will be set to "1", indicating the driver is available.
|
2016-10-03 21:00:32 +00:00
|
|
|
|
2015-10-08 19:18:44 +00:00
|
|
|
## Resource Isolation
|
|
|
|
|
|
|
|
The `raw_exec` driver provides no isolation.
|
2018-05-31 18:09:00 +00:00
|
|
|
|
|
|
|
If the launched process creates a new process group, it is possible that Nomad
|
|
|
|
will leak processes on shutdown unless the application forwards signals
|
|
|
|
properly. Nomad will not leak any processes if cgroups are being used to manage
|
|
|
|
the process tree. Cgroups are used on Linux when Nomad is being run with
|
2019-01-29 20:53:05 +00:00
|
|
|
appropriate privileges, the cgroup system is mounted and the operator hasn't
|
2018-05-31 18:09:00 +00:00
|
|
|
disabled cgroups for the driver.
|
2019-01-29 20:53:05 +00:00
|
|
|
|
|
|
|
[plugin-options]: #plugin-options
|
2020-02-06 23:45:31 +00:00
|
|
|
[plugin-stanza]: /docs/configuration/plugin
|