2015-09-20 22:31:33 +00:00
|
|
|
|
---
|
|
|
|
|
layout: "docs"
|
|
|
|
|
page_title: "Drivers: Exec"
|
|
|
|
|
sidebar_current: "docs-drivers-exec"
|
|
|
|
|
description: |-
|
|
|
|
|
The Exec task driver is used to run binaries using OS isolation primitives.
|
|
|
|
|
---
|
|
|
|
|
|
2015-10-08 18:36:22 +00:00
|
|
|
|
# Isolated Fork/Exec Driver
|
2015-09-20 22:31:33 +00:00
|
|
|
|
|
|
|
|
|
Name: `exec`
|
|
|
|
|
|
2015-09-20 22:42:33 +00:00
|
|
|
|
The `exec` driver is used to simply execute a particular command for a task.
|
2015-11-03 20:57:39 +00:00
|
|
|
|
However, unlike [`raw_exec`](raw_exec.html) it uses the underlying isolation
|
2015-10-08 19:18:44 +00:00
|
|
|
|
primitives of the operating system to limit the tasks access to resources. While
|
|
|
|
|
simple, since the `exec` driver can invoke any command, it can be used to call
|
|
|
|
|
scripts or other wrappers which provide higher level features.
|
2015-09-20 22:42:33 +00:00
|
|
|
|
|
|
|
|
|
## Task Configuration
|
|
|
|
|
|
|
|
|
|
The `exec` driver supports the following configuration in the job spec:
|
|
|
|
|
|
2015-11-18 23:16:42 +00:00
|
|
|
|
* `command` - The command to execute. Must be provided.
|
|
|
|
|
|
|
|
|
|
* `artifact_source` – (Optional) Source location of an executable artifact. Must
|
|
|
|
|
be accessible from the Nomad client. If you specify an `artifact_source` to be
|
|
|
|
|
executed, you must reference it in the `command` as show in the examples below
|
|
|
|
|
|
|
|
|
|
* `checksum` - (Optional) The checksum type and value for the `artifact_source`
|
|
|
|
|
image. The format is `type:value`, where type is any of `md5`, `sha1`,
|
|
|
|
|
`sha256`, or `sha512`, and the value is the computed checksum. If a checksum
|
|
|
|
|
is supplied and does not match the downloaded artifact, the driver will fail
|
|
|
|
|
to start
|
|
|
|
|
|
|
|
|
|
* `args` - (Optional) A list of arguments to the `command`.
|
2015-09-20 22:42:33 +00:00
|
|
|
|
|
|
|
|
|
## Client Requirements
|
|
|
|
|
|
2015-11-03 20:57:39 +00:00
|
|
|
|
The `exec` driver can only be run when on Linux and running Nomad as root.
|
|
|
|
|
`exec` is limited to this configuration because currently isolation of resources
|
|
|
|
|
is only guaranteed on Linux. Further the host must have cgroups mounted properly
|
|
|
|
|
in order for the driver to work.
|
2015-09-20 22:42:33 +00:00
|
|
|
|
|
2015-10-15 21:40:08 +00:00
|
|
|
|
You must specify a `command` to be executed. Optionally you can specify an
|
|
|
|
|
`artifact_source` to be downloaded as well. Any `command` is assumed to be present on the
|
|
|
|
|
running client, or a downloaded artifact.
|
|
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
|
|
|
|
|
To run a binary present on the Node:
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
config {
|
|
|
|
|
command = "/bin/sleep"
|
|
|
|
|
args = 1
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
To execute a binary specified by `artifact_source`:
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
config {
|
|
|
|
|
artifact_source = "https://dl.dropboxusercontent.com/u/1234/binary.bin"
|
2015-11-03 21:16:17 +00:00
|
|
|
|
checksum = "sha256:abd123445ds4555555555"
|
2015-10-15 21:40:08 +00:00
|
|
|
|
command = "$NOMAD_TASK_DIR/binary.bin"
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
2015-09-20 22:42:33 +00:00
|
|
|
|
## Client Attributes
|
|
|
|
|
|
|
|
|
|
The `exec` driver will set the following client attributes:
|
|
|
|
|
|
2015-09-23 01:31:13 +00:00
|
|
|
|
* `driver.exec` - This will be set to "1", indicating the
|
2015-09-20 22:42:33 +00:00
|
|
|
|
driver is available.
|
|
|
|
|
|
|
|
|
|
## Resource Isolation
|
|
|
|
|
|
|
|
|
|
The resource isolation provided varies by the operating system of
|
|
|
|
|
the client and the configuration.
|
|
|
|
|
|
2015-11-03 20:57:39 +00:00
|
|
|
|
On Linux, Nomad will use cgroups, and a chroot to isolate the
|
2015-09-23 01:31:13 +00:00
|
|
|
|
resources of a process and as such the Nomad agent must be run as root.
|