github.com/smintz/nomad@v0.8.3/website/source/docs/drivers/exec.html.md (about) 1 --- 2 layout: "docs" 3 page_title: "Drivers: Exec" 4 sidebar_current: "docs-drivers-exec" 5 description: |- 6 The Exec task driver is used to run binaries using OS isolation primitives. 7 --- 8 9 # Isolated Fork/Exec Driver 10 11 Name: `exec` 12 13 The `exec` driver is used to simply execute a particular command for a task. 14 However, unlike [`raw_exec`](raw_exec.html) it uses the underlying isolation 15 primitives of the operating system to limit the task's access to resources. While 16 simple, since the `exec` driver can invoke any command, it can be used to call 17 scripts or other wrappers which provide higher level features. 18 19 ## Task Configuration 20 21 ```hcl 22 task "webservice" { 23 driver = "exec" 24 25 config { 26 command = "my-binary" 27 args = ["-flag", "1"] 28 } 29 } 30 ``` 31 32 The `exec` driver supports the following configuration in the job spec: 33 34 * `command` - The command to execute. Must be provided. If executing a binary 35 that exists on the host, the path must be absolute. If executing a binary that 36 is downloaded from an [`artifact`](/docs/job-specification/artifact.html), the 37 path can be relative from the allocations's root directory. 38 39 * `args` - (Optional) A list of arguments to the `command`. References 40 to environment variables or any [interpretable Nomad 41 variables](/docs/runtime/interpolation.html) will be interpreted before 42 launching the task. 43 44 ## Examples 45 46 To run a binary present on the Node: 47 48 ```hcl 49 task "example" { 50 driver = "exec" 51 52 config { 53 # When running a binary that exists on the host, the path must be absolute. 54 command = "/bin/sleep" 55 args = ["1"] 56 } 57 } 58 ``` 59 60 To execute a binary downloaded from an 61 [`artifact`](/docs/job-specification/artifact.html): 62 63 ```hcl 64 task "example" { 65 driver = "exec" 66 67 config { 68 command = "name-of-my-binary" 69 } 70 71 artifact { 72 source = "https://internal.file.server/name-of-my-binary" 73 options { 74 checksum = "sha256:abd123445ds4555555555" 75 } 76 } 77 } 78 ``` 79 80 ## Client Requirements 81 82 The `exec` driver can only be run when on Linux and running Nomad as root. 83 `exec` is limited to this configuration because currently isolation of resources 84 is only guaranteed on Linux. Further, the host must have cgroups mounted properly 85 in order for the driver to work. 86 87 If you are receiving the error: 88 89 ``` 90 * Constraint "missing drivers" filtered <> nodes 91 ``` 92 93 and using the exec driver, check to ensure that you are running Nomad as root. 94 This also applies for running Nomad in -dev mode. 95 96 97 ## Client Attributes 98 99 The `exec` driver will set the following client attributes: 100 101 * `driver.exec` - This will be set to "1", indicating the driver is available. 102 103 ## Resource Isolation 104 105 The resource isolation provided varies by the operating system of 106 the client and the configuration. 107 108 On Linux, Nomad will use cgroups, and a chroot to isolate the 109 resources of a process and as such the Nomad agent must be run as root. 110 111 ### <a id="chroot"></a>Chroot 112 The chroot is populated with data in the following directories from the host 113 machine: 114 115 ``` 116 [ 117 "/bin", 118 "/etc", 119 "/lib", 120 "/lib32", 121 "/lib64", 122 "/run/resolvconf", 123 "/sbin", 124 "/usr", 125 ] 126 ``` 127 128 The task's chroot is populated by linking or copying the data from the host into 129 the chroot. Note that this can take considerable disk space. Since Nomad v0.5.3, 130 the client manages garbage collection locally which mitigates any issue this may 131 create. 132 133 This list is configurable through the agent client 134 [configuration file](/docs/agent/configuration/client.html#chroot_env).