github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/website/content/docs/commands/index.mdx (about)

     1  ---
     2  layout: docs
     3  page_title: Commands (CLI)
     4  description: >
     5    Nomad can be controlled via a command-line interface. This page documents all
     6    the commands Nomad accepts.
     7  ---
     8  
     9  # Nomad Commands (CLI)
    10  
    11  Nomad is controlled via a very easy to use command-line interface (CLI).
    12  Nomad is only a single command-line application: `nomad`, which
    13  takes a subcommand such as "agent" or "status". The complete list of
    14  subcommands is in the navigation to the left.
    15  
    16  The Nomad CLI is a well-behaved command line application. In erroneous cases,
    17  a non-zero exit status will be returned. It also responds to `-h` and `--help`
    18  as you would most likely expect.
    19  
    20  To view a list of the available commands at any time, just run Nomad
    21  with no arguments. To get help for any specific subcommand, run the subcommand
    22  with the `-h` argument.
    23  
    24  Each command has been conveniently documented on this website. Links to each
    25  command can be found on the left.
    26  
    27  ## Autocomplete
    28  
    29  Nomad's CLI supports command autocomplete. Autocomplete can be installed or
    30  uninstalled by running the following on bash, zsh or fish shells:
    31  
    32  ```shell-session
    33  $ nomad -autocomplete-install
    34  $ nomad -autocomplete-uninstall
    35  ```
    36  
    37  ## Command Contexts
    38  
    39  Nomad's CLI commands have implied contexts in their naming convention. Because
    40  the CLI is most commonly used to manipulate or query jobs, you can assume that
    41  any given command is working in that context unless the command name implies
    42  otherwise.
    43  
    44  For example, the `nomad job run` command is used to run a new job, the `nomad status` command queries information about existing jobs, etc. Conversely,
    45  commands with a prefix in their name likely operate in a different context.
    46  Examples include the `nomad agent-info` or `nomad node drain` commands,
    47  which operate in the agent or node contexts respectively.
    48  
    49  ### Remote Usage
    50  
    51  The Nomad CLI may be used to interact with a remote Nomad cluster, even when the
    52  local machine does not have a running Nomad agent. To do so, set the
    53  `NOMAD_ADDR` environment variable or use the `-address=<addr>` flag when running
    54  commands.
    55  
    56  ```shell-session
    57  $ NOMAD_ADDR=https://remote-address:4646 nomad status
    58  $ nomad status -address=https://remote-address:4646
    59  ```
    60  
    61  The provided address must be reachable from your local machine. There are a
    62  variety of ways to accomplish this (VPN, SSH Tunnel, etc). If the port is
    63  exposed to the public internet it is highly recommended to configure TLS.
    64  
    65  ### Environment Variables
    66  
    67  Nomad can use environment variables to configure command-line tool options.
    68  These environment variables can be overridden as needed using individual
    69  flags.
    70  
    71  #### Connection Environment Variables
    72  
    73  - `NOMAD_ADDR` - The address of the Nomad server. Defaults to
    74    `http://127.0.0.1:4646`.
    75  
    76  - `NOMAD_REGION` - The region of the Nomad server to forward commands to.
    77    Defaults to the Agent's local region
    78  
    79  - `NOMAD_NAMESPACE` - The target namespace for queries and actions bound to a
    80    namespace. If set to `*`, job and alloc subcommands query all namespacecs
    81    authorized to user. Defaults to the "default" namespace.
    82  
    83  - `NOMAD_HTTP_AUTH` - (Optional) This allows users to supply "Basic" HTTP
    84    authentication scheme ([RFC 7617](https://tools.ietf.org/html/rfc7617))
    85    information in environments where the Nomad API is behind an authenticating
    86    proxy server.
    87  
    88  #### ACL Environment Variables
    89  
    90  - `NOMAD_TOKEN` - The SecretID of an ACL token to use to authenticate API
    91    requests with.
    92  
    93  #### CLI Environment Variables
    94  
    95  - `NOMAD_CLI_NO_COLOR` - Disables colored command output.
    96  
    97  #### mTLS Environment Variables
    98  
    99  - `NOMAD_CLIENT_CERT` - Path to a PEM encoded client certificate for TLS
   100    authentication to the Nomad server. Must also specify `NOMAD_CLIENT_KEY`.
   101  
   102  - `NOMAD_CLIENT_KEY` - Path to an unencrypted PEM encoded private key matching
   103    the client certificate from `NOMAD_CLIENT_CERT`.
   104  
   105  - `NOMAD_CACERT` - Path to a PEM encoded CA cert file to use to verify the
   106    Nomad server SSL certificate.
   107  
   108  - `NOMAD_CAPATH` - Path to a directory of PEM encoded CA cert files to verify
   109    the Nomad server SSL certificate. If both `NOMAD_CACERT` and `NOMAD_CAPATH`
   110    are specified, `NOMAD_CACERT` is used.
   111  
   112  - `NOMAD_SKIP_VERIFY` - Do not verify TLS certificate. **This is highly not
   113    recommended.**
   114  
   115  - `NOMAD_TLS_SERVER_NAME` - The server name to use as the SNI host when
   116    connecting via TLS.
   117  
   118  #### Nomad Enterprise Licensing Environment Variables
   119  
   120  - `NOMAD_LICENSE_PATH` - An absolute path to a Nomad Enterprise license file,
   121    for example `/opt/nomad/license.hclic`.
   122  
   123  - `NOMAD_LICENSE` - The Nomad Enterprise license file contents as a string.