github.com/ferranbt/nomad@v0.9.3-0.20190607002617-85c449b7667c/website/source/docs/drivers/external/lxc.html.md (about) 1 --- 2 layout: "docs" 3 page_title: "Drivers: LXC" 4 sidebar_current: "docs-drivers-community-lxc" 5 description: |- 6 The LXC task driver is used to run application containers using LXC. 7 --- 8 9 # LXC Driver 10 11 Name: `lxc` 12 13 The `lxc` driver provides an interface for using LXC for running application 14 containers. You can download the external LXC driver [here][lxc-driver]. For more detailed instructions on how to set up and use this driver, please refer to the [LXC guide][lxc-guide]. 15 16 ~> The LXC client set up has changed in Nomad 0.9. You must use the new [plugin syntax][plugin] and install the external LXC driver in the [plugin_dir][plugin_dir] prior to upgrading. See [plugin options][plugin-options] below for an example. Note the job specification remains the same. 17 18 ## Task Configuration 19 20 ```hcl 21 task "busybox" { 22 driver = "lxc" 23 24 config { 25 log_level = "trace" 26 verbosity = "verbose" 27 template = "/usr/share/lxc/templates/lxc-busybox" 28 } 29 } 30 ``` 31 32 The `lxc` driver supports the following configuration in the job spec: 33 34 * `template` - The LXC template to run. 35 36 ```hcl 37 config { 38 template = "/usr/share/lxc/templates/lxc-alpine" 39 } 40 ``` 41 42 * `log_level` - (Optional) LXC library's logging level. Defaults to `error`. 43 Must be one of `trace`, `debug`, `info`, `warn`, or `error`. 44 45 ```hcl 46 config { 47 log_level = "debug" 48 } 49 ``` 50 51 * `verbosity` - (Optional) Enables extra verbosity in the LXC library's 52 logging. Defaults to `quiet`. Must be one of `quiet` or `verbose`. 53 54 ```hcl 55 config { 56 verbosity = "quiet" 57 } 58 ``` 59 60 * `volumes` - (Optional) A list of `host_path:container_path` strings to bind-mount host paths to container paths. Mounting host paths outside of the allocation directory can be disabled on clients by setting the [`volumes_enabled`](#volumes_enabled) option set to false. This will limit volumes to directories that exist inside the allocation directory. 61 62 Note that unlike the similar option for the docker driver, this 63 option must not have an absolute path as the `container_path` 64 component. This will cause an error when submitting a job. 65 66 Setting this does not affect the standard bind-mounts of `alloc`, 67 `local`, and `secrets`, which are always created. 68 69 ```hcl 70 config { 71 volumes = [ 72 # Use absolute paths to mount arbitrary paths on the host 73 "/path/on/host:path/in/container", 74 75 # Use relative paths to rebind paths already in the allocation dir 76 "relative/to/task:also/in/container" 77 ] 78 } 79 ``` 80 81 ## Networking 82 83 Currently the `lxc` driver only supports host networking. See the `none` 84 networking type in the `lxc.container.conf` [manual][lxc_man] for more 85 information. 86 87 ## Client Requirements 88 89 The `lxc` driver requires the following: 90 91 * 64-bit Linux host 92 * The `linux_amd64` Nomad binary 93 * The LXC driver binary placed in the [plugin_dir][plugin_dir] directory. 94 * `liblxc` to be installed 95 * `lxc-templates` to be installed 96 97 ## Plugin Options<a id="plugin_options"></a> 98 99 * `enabled` - The `lxc` driver may be disabled on hosts by setting this option to `false` (defaults to `true`). 100 101 * `volumes_enabled`<a id="volumes_enabled"></a> - Specifies whether host can bind-mount host paths to container paths (defaults to `true`). 102 103 * `lxc_path` - The location in which all containers are stored (commonly defaults to `/var/lib/lxc`). See [`lxc-create`][lxc-create] for more details. 104 105 An example of using these plugin options with the new [plugin 106 syntax][plugin] is shown below: 107 108 ```hcl 109 plugin "nomad-driver-lxc" { 110 config { 111 enabled = true 112 volumes_enabled = true 113 lxc_path = "/var/lib/lxc" 114 } 115 } 116 ``` 117 Please note the plugin name should match whatever name you have specified for the external driver in the [plugin_dir][plugin_dir] directory. 118 119 ## Client Configuration 120 121 ~> Only use this section for pre-0.9 releases of Nomad. If you are using Nomad 122 0.9 or above, please see [plugin options][plugin-options] 123 124 The `lxc` driver has the following [client configuration 125 options](/docs/configuration/client.html#options): 126 127 * `lxc.enable` - The `lxc` driver may be disabled on hosts by setting this 128 option to `false` (defaults to `true`). 129 130 ## Client Attributes 131 132 The `lxc` driver will set the following client attributes: 133 134 * `driver.lxc` - Set to `1` if LXC is found and enabled on the host node. 135 * `driver.lxc.version` - Version of `lxc` e.g.: `1.1.0`. 136 137 ## Resource Isolation 138 139 This driver supports CPU and memory isolation via the `lxc` library. Network 140 isolation is not supported as of now. 141 142 [lxc-create]: https://linuxcontainers.org/lxc/manpages/man1/lxc-create.1.html 143 [lxc-driver]: https://releases.hashicorp.com/nomad-driver-lxc 144 [lxc-guide]: /guides/operating-a-job/external/lxc.html 145 [lxc_man]: https://linuxcontainers.org/lxc/manpages/man5/lxc.container.conf.5.html#lbAM 146 [plugin]: /docs/configuration/plugin.html 147 [plugin_dir]: /docs/configuration/index.html#plugin_dir 148 [plugin-options]: #plugin_options