2015-09-12 00:01:02 +00:00
---
2020-02-06 23:45:31 +00:00
layout: docs
page_title: Commands (CLI)
2015-09-14 23:28:52 +00:00
description: >
Nomad can be controlled via a command-line interface. This page documents all
the commands Nomad accepts.
2015-09-12 00:01:02 +00:00
---
2015-09-14 23:28:52 +00:00
# Nomad Commands (CLI)
2015-09-12 00:01:02 +00:00
2015-09-14 23:28:52 +00:00
Nomad is controlled via a very easy to use command-line interface (CLI).
2019-10-22 13:44:00 +00:00
Nomad is only a single command-line application: `nomad`, which
2015-09-24 21:37:32 +00:00
takes a subcommand such as "agent" or "status". The complete list of
2015-09-12 00:01:02 +00:00
subcommands is in the navigation to the left.
2015-09-14 23:28:52 +00:00
The Nomad CLI is a well-behaved command line application. In erroneous cases,
2015-09-12 00:01:02 +00:00
a non-zero exit status will be returned. It also responds to `-h` and `--help`
2015-09-20 20:37:22 +00:00
as you would most likely expect.
2015-09-12 00:01:02 +00:00
2015-09-14 23:28:52 +00:00
To view a list of the available commands at any time, just run Nomad
2015-09-12 00:01:02 +00:00
with no arguments. To get help for any specific subcommand, run the subcommand
with the `-h` argument.
2015-09-14 23:54:05 +00:00
Each command has been conveniently documented on this website. Links to each
command can be found on the left.
2015-09-14 23:28:52 +00:00
2019-10-22 13:44:00 +00:00
## Autocomplete
2017-07-17 21:49:37 +00:00
Nomad's CLI supports command autocomplete. Autocomplete can be installed or
2022-05-02 13:26:55 +00:00
uninstalled by running the following on bash, zsh or fish shells:
2017-07-17 21:49:37 +00:00
2020-05-18 20:53:06 +00:00
```shell-session
$ nomad -autocomplete-install
2017-07-17 21:49:37 +00:00
$ nomad -autocomplete-uninstall
```
2019-10-22 13:44:00 +00:00
## Command Contexts
2015-09-14 23:28:52 +00:00
Nomad's CLI commands have implied contexts in their naming convention. Because
the CLI is most commonly used to manipulate or query jobs, you can assume that
any given command is working in that context unless the command name implies
otherwise.
2020-02-06 23:45:31 +00:00
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,
2015-09-14 23:28:52 +00:00
commands with a prefix in their name likely operate in a different context.
2018-03-22 20:39:18 +00:00
Examples include the `nomad agent-info` or `nomad node drain` commands,
2015-09-14 23:28:52 +00:00
which operate in the agent or node contexts respectively.
2017-03-28 10:08:35 +00:00
### Remote Usage
2017-03-28 16:47:57 +00:00
The Nomad CLI may be used to interact with a remote Nomad cluster, even when the
local machine does not have a running Nomad agent. To do so, set the
`NOMAD_ADDR` environment variable or use the `-address=<addr>` flag when running
commands.
2020-05-18 20:53:06 +00:00
```shell-session
2020-06-29 12:26:20 +00:00
$ NOMAD_ADDR=https://remote-address:4646 nomad status
2017-03-28 16:47:57 +00:00
$ nomad status -address=https://remote-address:4646
```
The provided address must be reachable from your local machine. There are a
variety of ways to accomplish this (VPN, SSH Tunnel, etc). If the port is
exposed to the public internet it is highly recommended to configure TLS.
2021-04-08 18:56:09 +00:00
### Environment Variables
Nomad can use environment variables to configure command-line tool options.
These environment variables can be overridden as needed using individual
flags.
#### Connection Environment Variables
- `NOMAD_ADDR` - The address of the Nomad server. Defaults to
`http://127.0.0.1:4646`.
- `NOMAD_REGION` - The region of the Nomad server to forward commands to.
Defaults to the Agent's local region
- `NOMAD_NAMESPACE` - The target namespace for queries and actions bound to a
namespace. If set to `*`, job and alloc subcommands query all namespacecs
authorized to user. Defaults to the "default" namespace.
- `NOMAD_HTTP_AUTH` - (Optional) This allows users to supply "Basic" HTTP
authentication scheme ([RFC 7617](https://tools.ietf.org/html/rfc7617))
information in environments where the Nomad API is behind an authenticating
proxy server.
#### ACL Environment Variables
- `NOMAD_TOKEN` - The SecretID of an ACL token to use to authenticate API
requests with.
#### CLI Environment Variables
- `NOMAD_CLI_NO_COLOR` - Disables colored command output.
#### mTLS Environment Variables
- `NOMAD_CLIENT_CERT` - Path to a PEM encoded client certificate for TLS
authentication to the Nomad server. Must also specify `NOMAD_CLIENT_KEY`.
- `NOMAD_CLIENT_KEY` - Path to an unencrypted PEM encoded private key matching
the client certificate from `NOMAD_CLIENT_CERT`.
- `NOMAD_CACERT` - Path to a PEM encoded CA cert file to use to verify the
Nomad server SSL certificate.
- `NOMAD_CAPATH` - Path to a directory of PEM encoded CA cert files to verify
the Nomad server SSL certificate. If both `NOMAD_CACERT` and `NOMAD_CAPATH`
are specified, `NOMAD_CACERT` is used.
- `NOMAD_SKIP_VERIFY` - Do not verify TLS certificate. **This is highly not
recommended.**
- `NOMAD_TLS_SERVER_NAME` - The server name to use as the SNI host when
connecting via TLS.
#### Nomad Enterprise Licensing Environment Variables
- `NOMAD_LICENSE_PATH` - An absolute path to a Nomad Enterprise license file,
for example `/opt/nomad/license.hclic`.
- `NOMAD_LICENSE` - The Nomad Enterprise license file contents as a string.