github.com/ryanslade/nomad@v0.2.4-0.20160128061903-fc95782f2089/website/source/docs/jobspec/environment.html.md (about) 1 --- 2 layout: "docs" 3 page_title: "Runtime Environment" 4 sidebar_current: "docs-jobspec-environment" 5 description: |- 6 Learn how to configure the Nomad runtime environment. 7 --- 8 9 # Runtime Environment 10 11 Some settings you specify in your [job specification](/docs/jobspec/) are passed to tasks 12 when they start. Other settings are dynamically allocated when your job is 13 scheduled. Both types of values are made available to your job through 14 environment variables. 15 16 ## Resources 17 18 When you request resources for a job, Nomad creates a resource offer. The final 19 resources for your job are not determined until it is scheduled. Nomad will 20 tell you which resources have been allocated after evaluation and placement. 21 22 ### CPU and Memory 23 24 Nomad will pass CPU and memory limits to your job as `NOMAD_CPU_LIMIT` and 25 `NOMAD_MEMORY_LIMIT`. Your task should use these values to adapt its behavior to 26 fit inside the resource allocation that nomad provides. For example, you can use 27 the memory limit to inform how large your in-process cache should be, or to 28 decide when to flush buffers to disk. 29 30 Both CPU and memory are presented as integers. The unit for CPU limit is 31 `1024 = 1Ghz`. The unit for memory is `1 = 1 megabytes`. 32 33 Writing your applications to adjust to these values at runtime provides greater 34 scheduling flexibility since you can adjust the resource allocations in your 35 job specification without needing to change your code. You can also schedule workloads 36 that accept dynamic resource allocations so they can scale down/up as your 37 cluster gets more or less busy. 38 39 ### Networking 40 41 Nomad assigns IPs and ports to your jobs and exposes them via environment 42 variables. See the [Networking](/docs/jobspec/networking.html) page for more 43 details. 44 45 ### Task Directories <a id="task_dir"></a> 46 47 Nomad makes the following two directories available to tasks: 48 49 * `alloc/`: This directory is shared across all tasks in a task group and can be 50 used to store data that needs to be used by multiple tasks, such as a log 51 shipper. 52 * `local/`: This directory is private to each task. It can be used to store 53 arbitrary data that shouldn't be shared by tasks in the task group. 54 55 Both these directories are persisted until the allocation is removed, which 56 occurs hours after all the tasks in the task group enter terminal states. This 57 gives time to view the data produced by tasks. 58 59 Depending on the driver and operating system being targeted, the directories are 60 made available in various ways. For example, on `docker` the directories are 61 binded to the container, while on `exec` on Linux the directories are mounted into the 62 chroot. Regardless of how the directories are made available, the path to the 63 directories can be read through the following environment variables: 64 `NOMAD_ALLOC_DIR` and `NOMAD_TASK_DIR`. 65 66 ## Meta 67 68 The job specification also allows you to specify a `meta` block to supply arbitrary 69 configuration to a task. This allows you to easily provide job-specific 70 configuration even if you use the same executable unit in multiple jobs. These 71 key-value pairs are passed through to the job as `NOMAD_META_{KEY}={value}`, 72 where `key` is UPPERCASED from the job specification. 73 74 Currently there is no enforcement that the meta values be lowercase, but using 75 multiple keys with the same uppercased representation will lead to undefined 76 behavior.