github.com/anuvu/nomad@v0.8.7-atom1/website/source/docs/drivers/docker.html.md (about)

     1  ---
     2  layout: "docs"
     3  page_title: "Drivers: Docker"
     4  sidebar_current: "docs-drivers-docker"
     5  description: |-
     6    The Docker task driver is used to run Docker based tasks.
     7  ---
     8  
     9  # Docker Driver
    10  
    11  Name: `docker`
    12  
    13  The `docker` driver provides a first-class Docker workflow on Nomad. The Docker
    14  driver handles downloading containers, mapping ports, and starting, watching,
    15  and cleaning up after containers.
    16  
    17  ## Task Configuration
    18  
    19  ```hcl
    20  task "webservice" {
    21    driver = "docker"
    22  
    23    config {
    24      image = "redis:3.2"
    25      labels {
    26        group = "webservice-cache"
    27      }
    28    }
    29  }
    30  ```
    31  
    32  The `docker` driver supports the following configuration in the job spec.  Only
    33  `image` is required.
    34  
    35  * `image` - The Docker image to run. The image may include a tag or custom URL
    36    and should include `https://` if required. By default it will be fetched from
    37    Docker Hub. If the tag is omitted or equal to `latest` the driver will always
    38    try to pull the image. If the image to be pulled exists in a registry that
    39    requires authentication credentials must be provided to Nomad. Please see the
    40    [Authentication section](#authentication).
    41  
    42      ```hcl
    43      config {
    44        image = "https://hub.docker.internal/redis:3.2"
    45      }
    46      ```
    47  
    48  * `args` - (Optional) A list of arguments to the optional `command`. If no
    49    `command` is specified, the arguments are passed directly to the container.
    50    References to environment variables or any [interpretable Nomad
    51    variables](/docs/runtime/interpolation.html) will be interpreted before
    52    launching the task. For example:
    53  
    54      ```hcl
    55      config {
    56        args = [
    57          "-bind", "${NOMAD_PORT_http}",
    58          "${nomad.datacenter}",
    59          "${MY_ENV}",
    60          "${meta.foo}",
    61        ]
    62      }
    63      ```
    64  
    65  * `auth` - (Optional) Provide authentication for a private registry (see below).
    66  
    67  * `auth_soft_fail` `(bool: false)` - Don't fail the task on an auth failure.
    68    Attempt to continue without auth.
    69  
    70  * `command` - (Optional) The command to run when starting the container.
    71  
    72      ```hcl
    73      config {
    74        command = "my-command"
    75      }
    76      ```
    77      
    78  * `dns_search_domains` - (Optional) A list of DNS search domains for the container
    79    to use.
    80  
    81  * `dns_options` - (Optional) A list of DNS options for the container to use.
    82  
    83  * `dns_servers` - (Optional) A list of DNS servers for the container to use
    84    (e.g. ["8.8.8.8", "8.8.4.4"]). Requires Docker v1.10 or greater.
    85  
    86  * `entrypoint` - (Optional) A string list overriding the image's entrypoint.
    87  
    88  * `extra_hosts` - (Optional) A list of hosts, given as host:IP, to be added to
    89    `/etc/hosts`.
    90  
    91  * `force_pull` - (Optional) `true` or `false` (default). Always pull latest image
    92    instead of using existing local image. Should be set to `true` if repository tags
    93    are mutable.
    94  
    95  * `hostname` - (Optional) The hostname to assign to the container. When
    96    launching more than one of a task (using `count`) with this option set, every
    97    container the task starts will have the same hostname.
    98  
    99  * `interactive` - (Optional) `true` or `false` (default). Keep STDIN open on
   100    the container.
   101  
   102  * `sysctl` - (Optional) A key-value map of sysctl configurations to set to the
   103     containers on start.
   104  
   105      ```hcl
   106      config {
   107        sysctl {
   108          net.core.somaxconn = "16384"
   109        }
   110      }
   111      ```
   112  
   113  * `ulimit` - (Optional) A key-value map of ulimit configurations to set to the
   114    containers on start.
   115  
   116      ```hcl
   117      config {
   118        ulimit {
   119          nproc = "4242"
   120          nofile = "2048:4096"
   121        }
   122      }
   123      ```
   124  
   125  * `privileged` - (Optional) `true` or `false` (default). Privileged mode gives
   126    the container access to devices on the host. Note that this also requires the
   127    nomad agent and docker daemon to be configured to allow privileged
   128    containers.
   129  
   130  * `ipc_mode` - (Optional) The IPC mode to be used for the container. The default
   131    is `none` for a private IPC namespace. Other values are `host` for sharing
   132    the host IPC namespace or the name or id of an existing container. Note that
   133    it is not possible to refer to Docker containers started by Nomad since their
   134    names are not known in advance. Note that setting this option also requires the
   135    Nomad agent to be configured to allow privileged containers.
   136  
   137  * `ipv4_address` - (Optional) The IPv4 address to be used for the container when
   138    using user defined networks. Requires Docker 1.13 or greater.
   139  
   140  * `ipv6_address` - (Optional) The IPv6 address to be used for the container when
   141    using user defined networks. Requires Docker 1.13 or greater.
   142  
   143  * `labels` - (Optional) A key-value map of labels to set to the containers on
   144    start.
   145  
   146      ```hcl
   147      config {
   148        labels {
   149          foo = "bar"
   150          zip = "zap"
   151        }
   152      }
   153      ```
   154  
   155  * `load` - (Optional) Load an image from a `tar` archive file instead of from a
   156    remote repository. Equivalent to the `docker load -i <filename>` command.
   157  
   158      ```hcl
   159      artifact {
   160        source = "http://path.to/redis.tar"
   161      }
   162      config {
   163        load = "redis.tar"
   164        image = "redis"
   165      }
   166      ```
   167  
   168  * `logging` - (Optional) A key-value map of Docker logging options. The default
   169    value is `syslog`.
   170  
   171      ```hcl
   172      config {
   173        logging {
   174          type = "fluentd"
   175          config {
   176            fluentd-address = "localhost:24224"
   177            tag = "your_tag"
   178          }
   179        }
   180      }
   181      ```
   182  
   183  * `mac_address` - (Optional) The MAC address for the container to use (e.g.
   184    "02:68:b3:29:da:98").
   185  
   186  * `network_aliases` - (Optional) A list of network-scoped aliases, provide a way for a
   187    container to be discovered by an alternate name by any other container within
   188    the scope of a particular network. Network-scoped alias is supported only for
   189    containers in user defined networks
   190  
   191      ```hcl
   192      config {
   193        network_mode = "user-network"
   194        network_aliases = [
   195          "${NOMAD_TASK_NAME}",
   196          "${NOMAD_TASK_NAME}-${NOMAD_ALLOC_INDEX}"
   197        ]
   198      }
   199      ```
   200  
   201  * `network_mode` - (Optional) The network mode to be used for the container. In
   202    order to support userspace networking plugins in Docker 1.9 this accepts any
   203    value. The default is `bridge` for all operating systems but Windows, which
   204    defaults to `nat`. Other networking modes may not work without additional
   205    configuration on the host (which is outside the scope of Nomad).  Valid values
   206    pre-docker 1.9 are `default`, `bridge`, `host`, `none`, or `container:name`.
   207  
   208  * `pid_mode` - (Optional) `host` or not set (default). Set to `host` to share
   209    the PID namespace with the host. Note that this also requires the Nomad agent
   210    to be configured to allow privileged containers.
   211    See below for more details.
   212  
   213  * `port_map` - (Optional) A key-value map of port labels (see below).
   214  
   215  * `security_opt` - (Optional) A list of string flags to pass directly to
   216    [`--security-opt`](https://docs.docker.com/engine/reference/run/#security-configuration).
   217    For example:
   218  
   219  
   220      ```hcl
   221      config {
   222        security_opt = [
   223          "credentialspec=file://gmsaUser.json",
   224        ]
   225      }
   226      ```
   227  
   228  * `shm_size` - (Optional) The size (bytes) of /dev/shm for the container.
   229  
   230  * `SSL` - (Optional) If this is set to true, Nomad uses SSL to talk to the
   231    repository. The default value is `true`. **Deprecated as of 0.5.3**
   232  
   233  * `tty` - (Optional) `true` or `false` (default). Allocate a pseudo-TTY for the
   234    container.
   235  
   236  * `uts_mode` - (Optional) `host` or not set (default). Set to `host` to share
   237    the UTS namespace with the host. Note that this also requires the Nomad agent
   238    to be configured to allow privileged containers.
   239  
   240  * `userns_mode` - (Optional) `host` or not set (default). Set to `host` to use
   241    the host's user namespace when user namespace remapping is enabled on the
   242    docker daemon.
   243  
   244  * `volumes` - (Optional) A list of `host_path:container_path` strings to bind
   245    host paths to container paths. Mounting host paths outside of the allocation
   246    directory can be disabled on clients by setting the `docker.volumes.enabled`
   247    option set to false. This will limit volumes to directories that exist inside
   248    the allocation directory.
   249  
   250      ```hcl
   251      config {
   252        volumes = [
   253          # Use absolute paths to mount arbitrary paths on the host
   254          "/path/on/host:/path/in/container",
   255  
   256          # Use relative paths to rebind paths already in the allocation dir
   257          "relative/to/task:/also/in/container"
   258        ]
   259      }
   260      ```
   261  
   262  * `volume_driver` - (Optional) The name of the volume driver used to mount
   263    volumes. Must be used along with `volumes`.
   264    Using a `volume_driver` also allows to use `volumes` with a named volume as
   265    well as absolute paths. If `docker.volumes.enabled` is false then volume
   266    drivers are disallowed.
   267  
   268      ```hcl
   269      config {
   270        volumes = [
   271          # Use named volume created outside nomad.
   272          "name-of-the-volume:/path/in/container"
   273        ]
   274        # Name of the Docker Volume Driver used by the container
   275        volume_driver = "pxd"
   276      }
   277      ```
   278  
   279  * `work_dir` - (Optional) The working directory inside the container.
   280  
   281  * `mounts` - (Optional) A list of
   282    [mounts](https://docs.docker.com/engine/reference/commandline/service_create/#add-bind-mounts-or-volumes)
   283    to be mounted into the container. Only volume type mounts are supported.
   284  
   285      ```hcl
   286      config {
   287        mounts = [
   288          {
   289            target = "/path/in/container"
   290            source = "name-of-volume"
   291            readonly = false
   292            volume_options {
   293              no_copy = false
   294              labels {
   295                foo = "bar"
   296              }
   297              driver_config {
   298                name = "pxd"
   299                options = {
   300                  foo = "bar"
   301                }
   302              }
   303            }
   304          }
   305        ]
   306      }
   307      ```
   308  * `devices` - (Optional) A list of
   309    [devices](https://docs.docker.com/engine/reference/commandline/run/#add-host-device-to-container-device)
   310    to be exposed the container. `host_path` is the only required field. By default, the container will be able to
   311    `read`, `write` and `mknod` these devices. Use the optional `cgroup_permissions` field to restrict permissions.
   312  
   313      ```hcl
   314      config {
   315        devices = [
   316          {
   317            host_path = "/dev/sda1"
   318            container_path = "/dev/xvdc"
   319            cgroup_permissions = "r"
   320          },
   321          {
   322            host_path = "/dev/sda2"
   323            container_path = "/dev/xvdd"
   324          }
   325        ]
   326      }
   327      ```
   328  
   329  * `cap_add` - (Optional) A list of Linux capabilities as strings to pass directly to
   330    [`--cap-add`](https://docs.docker.com/engine/reference/run/#runtime-privilege-and-linux-capabilities).
   331    Effective capabilities (computed from `cap_add` and `cap_drop`) have to match the configured whitelist.
   332    The whitelist can be customized using the `docker.caps.whitelist` key in the client node's configuration.
   333    For example:
   334  
   335  
   336      ```hcl
   337      config {
   338        cap_add = [
   339          "SYS_TIME",
   340        ]
   341      }
   342      ```
   343  
   344  * `cap_drop` - (Optional) A list of Linux capabilities as strings to pass directly to
   345    [`--cap-drop`](https://docs.docker.com/engine/reference/run/#runtime-privilege-and-linux-capabilities).
   346    Effective capabilities (computed from `cap_add` and `cap_drop`) have to match the configured whitelist.
   347    The whitelist can be customized using the `docker.caps.whitelist` key in the client node's configuration.
   348    For example:
   349  
   350  
   351      ```hcl
   352      config {
   353        cap_drop = [
   354          "MKNOD",
   355        ]
   356      }
   357      ```
   358  
   359  * `cpu_hard_limit` - (Optional) `true` or `false` (default). Use hard CPU
   360    limiting instead of soft limiting. By default this is `false` which means
   361    soft limiting is used and containers are able to burst above their CPU limit
   362    when there is idle capacity.
   363  
   364  * `advertise_ipv6_address` - (Optional) `true` or `false` (default). Use the container's 
   365     IPv6 address (GlobalIPv6Address in Docker) when registering services and checks.
   366     See [IPv6 Docker containers](/docs/job-specification/service.html#IPv6 Docker containers) for details.
   367  
   368  * `readonly_rootfs` - (Optional) `true` or `false` (default). Mount
   369    the container's filesystem as read only.
   370  
   371  * `pids_limit` - (Optional) An integer value that specifies the pid limit for
   372    the container. Defaults to unlimited.
   373  
   374  ### Container Name
   375  
   376  Nomad creates a container after pulling an image. Containers are named
   377  `{taskName}-{allocId}`. This is necessary in order to place more than one
   378  container from the same task on a host (e.g. with count > 1). This also means
   379  that each container's name is unique across the cluster.
   380  
   381  This is not configurable.
   382  
   383  ### Authentication
   384  
   385  If you want to pull from a private repo (for example on dockerhub or quay.io),
   386  you will need to specify credentials in your job via:
   387  
   388   * the `auth` option in the task config.
   389  
   390   * by storing explicit repository credentials or by specifying Docker
   391     `credHelpers` in a file and setting the [docker.auth.config](#auth_file)
   392     value on the client.
   393  
   394   * by specifying a [docker.auth.helper](#auth_helper) on the client
   395  
   396  The `auth` object supports the following keys:
   397  
   398  * `username` - (Optional) The account username.
   399  
   400  * `password` - (Optional) The account password.
   401  
   402  * `email` - (Optional) The account email.
   403  
   404  * `server_address` - (Optional) The server domain/IP without the protocol.
   405    Docker Hub is used by default.
   406  
   407  Example task-config:
   408  
   409  ```hcl
   410  task "example" {
   411    driver = "docker"
   412  
   413    config {
   414      image = "secret/service"
   415  
   416      auth {
   417        username = "dockerhub_user"
   418        password = "dockerhub_password"
   419      }
   420    }
   421  }
   422  ```
   423  
   424  Example docker-config, using two helper scripts in $PATH,
   425  "docker-credential-ecr" and "docker-credential-vault":
   426  
   427  ```json
   428  {
   429    "auths": {
   430      "internal.repo": { "auth": "`echo -n '<username>:<password>' | base64 -w0`" }
   431    },
   432    "credHelpers": {
   433        "<XYZ>.dkr.ecr.<region>.amazonaws.com": "ecr-login"
   434    },
   435    "credsStore": "secretservice"
   436  }
   437  ```
   438  
   439  Example agent configuration, using a helper script "docker-credential-ecr" in
   440  $PATH
   441  
   442  ```hcl
   443  client {
   444    enabled = true
   445    options {
   446      "docker.auth.helper" = "ecr"
   447    }
   448  }
   449  ```
   450  !> **Be Careful!** At this time these credentials are stored in Nomad in plain
   451  text. Secrets management will be added in a later release.
   452  
   453  ## Networking
   454  
   455  Docker supports a variety of networking configurations, including using host
   456  interfaces, SDNs, etc. Nomad uses `bridged` networking by default, like Docker.
   457  
   458  You can specify other networking options, including custom networking plugins
   459  in Docker 1.9. **You may need to perform additional configuration on the host
   460  in order to make these work.** This additional configuration is outside the
   461  scope of Nomad.
   462  
   463  ### Allocating Ports
   464  
   465  You can allocate ports to your task using the port syntax described on the
   466  [networking page](/docs/job-specification/network.html). Here is a recap:
   467  
   468  ```hcl
   469  task "example" {
   470    driver = "docker"
   471  
   472    resources {
   473      network {
   474        port "http" {}
   475        port "https" {}
   476      }
   477    }
   478  }
   479  ```
   480  
   481  ### Forwarding and Exposing Ports
   482  
   483  A Docker container typically specifies which port a service will listen on by
   484  specifying the `EXPOSE` directive in the `Dockerfile`.
   485  
   486  Because dynamic ports will not match the ports exposed in your Dockerfile,
   487  Nomad will automatically expose all of the ports it allocates to your
   488  container.
   489  
   490  These ports will be identified via environment variables. For example:
   491  
   492  ```hcl
   493  port "http" {}
   494  ```
   495  
   496  If Nomad allocates port `23332` to your task for `http`, `23332` will be
   497  automatically exposed and forwarded to your container, and the driver will set
   498  an environment variable `NOMAD_PORT_http` with the value `23332` that you can
   499  read inside your container.
   500  
   501  This provides an easy way to use the `host` networking option for better
   502  performance.
   503  
   504  ### Using the Port Map
   505  
   506  If you prefer to use the traditional port-mapping method, you can specify the
   507  `port_map` option in your job specification. It looks like this:
   508  
   509  ```hcl
   510  task "example" {
   511    driver = "docker"
   512  
   513    config {
   514      image = "redis"
   515  
   516      port_map {
   517        redis = 6379
   518      }
   519    }
   520  
   521    resources {
   522      network {
   523        mbits = 20
   524        port "redis" {}
   525      }
   526    }
   527  }
   528  ```
   529  
   530  If Nomad allocates port `23332` to your task, the Docker driver will
   531  automatically setup the port mapping from `23332` on the host to `6379` in your
   532  container, so it will just work!
   533  
   534  Note that by default this only works with `bridged` networking mode. It may
   535  also work with custom networking plugins which implement the same API for
   536  expose and port forwarding.
   537  
   538  ### Advertising Container IPs
   539  
   540  *New in Nomad 0.6.*
   541  
   542  When using network plugins like `weave` that assign containers a routable IP
   543  address, that address will automatically be used in any `service`
   544  advertisements for the task. You may override what address is advertised by
   545  using the `address_mode` parameter on a `service`. See
   546  [service](/docs/job-specification/service.html) for details.
   547  
   548  ### Networking Protocols
   549  
   550  The Docker driver configures ports on both the `tcp` and `udp` protocols.
   551  
   552  This is not configurable.
   553  
   554  ### Other Networking Modes
   555  
   556  Some networking modes like `container` or `none` will require coordination
   557  outside of Nomad. First-class support for these options may be improved later
   558  through Nomad plugins or dynamic job configuration.
   559  
   560  ## Client Requirements
   561  
   562  Nomad requires Docker to be installed and running on the host alongside the
   563  Nomad agent. Nomad was developed against Docker `1.8.2` and `1.9`.
   564  
   565  By default Nomad communicates with the Docker daemon using the daemon's Unix
   566  socket. Nomad will need to be able to read/write to this socket. If you do not
   567  run Nomad as root, make sure you add the Nomad user to the Docker group so
   568  Nomad can communicate with the Docker daemon.
   569  
   570  For example, on Ubuntu you can use the `usermod` command to add the `vagrant`
   571  user to the `docker` group so you can run Nomad without root:
   572  
   573      sudo usermod -G docker -a vagrant
   574  
   575  For the best performance and security features you should use recent versions
   576  of the Linux Kernel and Docker daemon.
   577  
   578  ## Client Configuration
   579  
   580  The `docker` driver has the following [client configuration
   581  options](/docs/agent/configuration/client.html#options):
   582  
   583  * `docker.endpoint` - If using a non-standard socket, HTTP or another location,
   584    or if TLS is being used, `docker.endpoint` must be set. If unset, Nomad will
   585    attempt to instantiate a Docker client using the `DOCKER_HOST` environment
   586    variable and then fall back to the default listen address for the given
   587    operating system. Defaults to `unix:///var/run/docker.sock` on Unix platforms
   588    and `npipe:////./pipe/docker_engine` for Windows.
   589  
   590  * `docker.auth.config` <a id="auth_file"></a>- Allows an operator to specify a
   591    JSON file which is in the dockercfg format containing authentication
   592    information for a private registry, from either (in order) `auths`,
   593    `credHelpers` or `credsStore`.
   594  
   595  * `docker.auth.helper` <a id="auth_helper"></a>- Allows an operator to specify
   596    a [credsStore](https://docs.docker.com/engine/reference/commandline/login/#credential-helper-protocol)
   597    -like script on $PATH to lookup authentication information from external
   598    sources. The script's name must begin with `docker-credential-` and this
   599    option should include only the basename of the script, not the path.
   600  
   601  * `docker.tls.cert` - Path to the server's certificate file (`.pem`). Specify
   602    this along with `docker.tls.key` and `docker.tls.ca` to use a TLS client to
   603    connect to the docker daemon. `docker.endpoint` must also be specified or
   604    this setting will be ignored.
   605  
   606  * `docker.tls.key` - Path to the client's private key (`.pem`). Specify this
   607    along with `docker.tls.cert` and `docker.tls.ca` to use a TLS client to
   608    connect to the docker daemon. `docker.endpoint` must also be specified or
   609    this setting will be ignored.
   610  
   611  * `docker.tls.ca` - Path to the server's CA file (`.pem`). Specify this along
   612    with `docker.tls.cert` and `docker.tls.key` to use a TLS client to connect to
   613    the docker daemon. `docker.endpoint` must also be specified or this setting
   614    will be ignored.
   615  
   616  * `docker.cleanup.image` Defaults to `true`. Changing this to `false` will
   617    prevent Nomad from removing images from stopped tasks.
   618  
   619  * `docker.cleanup.image.delay` A time duration, as [defined
   620    here](https://golang.org/pkg/time/#ParseDuration), that defaults to `3m`. The
   621    delay controls how long Nomad will wait between an image being unused and
   622    deleting it. If a tasks is received that uses the same image within the delay,
   623    the image will be reused.
   624  
   625  * `docker.volumes.enabled`: Defaults to `true`. Allows tasks to bind host paths
   626    (`volumes`) inside their container and use volume drivers (`volume_driver`).
   627    Binding relative paths is always allowed and will be resolved relative to the
   628    allocation's directory.
   629  
   630  * `docker.volumes.selinuxlabel`: Allows the operator to set a SELinux
   631    label to the allocation and task local bind-mounts to containers. If used
   632    with `docker.volumes.enabled` set to false, the labels will still be applied
   633    to the standard binds in the container.
   634  
   635  * `docker.privileged.enabled` Defaults to `false`. Changing this to `true` will
   636    allow containers to use `privileged` mode, which gives the containers full
   637    access to the host's devices. Note that you must set a similar setting on the
   638    Docker daemon for this to work.
   639  
   640  * `docker.caps.whitelist`: A list of allowed Linux capabilities. Defaults to
   641    `"CHOWN,DAC_OVERRIDE,FSETID,FOWNER,MKNOD,NET_RAW,SETGID,SETUID,SETFCAP,SETPCAP,NET_BIND_SERVICE,SYS_CHROOT,KILL,AUDIT_WRITE"`,
   642    which is the list of capabilities allowed by docker by default, as 
   643    [defined here](https://docs.docker.com/engine/reference/run/#runtime-privilege-and-linux-capabilities).
   644    Allows the operator to control which capabilities can be obtained by 
   645    tasks using `cap_add` and `cap_drop` options. Supports the value `"ALL"` as a 
   646    shortcut for whitelisting all capabilities.
   647  
   648  * `docker.cleanup.container`: Defaults to `true`. This option can be used to
   649    disable Nomad from removing a container when the task exits. Under a name
   650    conflict, Nomad may still remove the dead container.
   651  
   652  Note: When testing or using the `-dev` flag you can use `DOCKER_HOST`,
   653  `DOCKER_TLS_VERIFY`, and `DOCKER_CERT_PATH` to customize Nomad's behavior. If
   654  `docker.endpoint` is set Nomad will **only** read client configuration from the
   655  config file.
   656  
   657  An example is given below:
   658  
   659  ```hcl
   660  client {
   661    options {
   662      "docker.cleanup.image" = "false"
   663    }
   664  }
   665  ```
   666  
   667  ## Client Attributes
   668  
   669  The `docker` driver will set the following client attributes:
   670  
   671  * `driver.docker` - This will be set to "1", indicating the driver is
   672    available.
   673  * `driver.docker.bridge_ip` - The IP of the Docker bridge network if one
   674    exists.
   675  * `driver.docker.version` - This will be set to version of the docker server.
   676  
   677  Here is an example of using these properties in a job file:
   678  
   679  ```hcl
   680  job "docs" {
   681    # Require docker version higher than 1.2.
   682    constraint {
   683      attribute = "${driver.docker.version}"
   684      operator  = ">"
   685      version   = "1.2"
   686    }
   687  }
   688  ```
   689  
   690  ## Resource Isolation
   691  
   692  ### CPU
   693  
   694  Nomad limits containers' CPU based on CPU shares. CPU shares allow containers
   695  to burst past their CPU limits. CPU limits will only be imposed when there is
   696  contention for resources. When the host is under load your process may be
   697  throttled to stabilize QoS depending on how many shares it has. You can see how
   698  many CPU shares are available to your process by reading `NOMAD_CPU_LIMIT`.
   699  1000 shares are approximately equal to 1 GHz.
   700  
   701  Please keep the implications of CPU shares in mind when you load test workloads
   702  on Nomad.
   703  
   704  ### Memory
   705  
   706  Nomad limits containers' memory usage based on total virtual memory. This means
   707  that containers scheduled by Nomad cannot use swap. This is to ensure that a
   708  swappy process does not degrade performance for other workloads on the same
   709  host.
   710  
   711  Since memory is not an elastic resource, you will need to make sure your
   712  container does not exceed the amount of memory allocated to it, or it will be
   713  terminated or crash when it tries to malloc. A process can inspect its memory
   714  limit by reading `NOMAD_MEMORY_LIMIT`, but will need to track its own memory
   715  usage. Memory limit is expressed in megabytes so 1024 = 1 GB.
   716  
   717  ### IO
   718  
   719  Nomad's Docker integration does not currently provide QoS around network or
   720  filesystem IO. These will be added in a later release.
   721  
   722  ### Security
   723  
   724  Docker provides resource isolation by way of
   725  [cgroups and namespaces](https://docs.docker.com/introduction/understanding-docker/#the-underlying-technology).
   726  Containers essentially have a virtual file system all to themselves. If you
   727  need a higher degree of isolation between processes for security or other
   728  reasons, it is recommended to use full virtualization like
   729  [QEMU](/docs/drivers/qemu.html).
   730  
   731  ## Docker for Mac Caveats
   732  
   733  Docker for Mac runs Docker inside a small VM and then allows access to parts of
   734  the host filesystem into that VM. At present, nomad uses a syslog server bound to
   735  a Unix socket within a path that both the host and the VM can access to forward
   736  log messages back to nomad. But at present, Docker For Mac does not work for
   737  Unix domain sockets (https://github.com/docker/for-mac/issues/483) in one of
   738  these shared paths.
   739  
   740  As a result, using nomad with the docker driver on OS X/macOS will work, but no
   741  logs will be available to nomad. Users must use the native docker facilities to
   742  examine the logs of any jobs running under docker.
   743  
   744  In the future, we will resolve this issue, one way or another.
   745  
   746  ## Docker for Windows Caveats
   747  
   748  Docker for Windows only supports running Windows containers. Because Docker for
   749  Windows is relatively new and rapidly evolving you may want to consult the
   750  [list of relevant issues on GitHub][WinIssues].
   751  
   752  [WinIssues]: https://github.com/hashicorp/nomad/issues?q=is%3Aopen+is%3Aissue+label%3Adriver%2Fdocker+label%3Aplatform-windows