Nomad
Nomad command-line interface (CLI) reference
The Nomad CLI is a well-behaved command-line application. In erroneous cases,
the CLI returns a non-zero exit status. To view a list of available commands,
run the nomad
command with no arguments, -h
, or --help
. To access help for
any specific subcommand, run the subcommand with the -h
argument.
Autocomplete
Nomad's CLI supports command autocomplete.
To install autocomplete, run the nomad
command with the
-autocomplete-install
option.
$ nomad -autocomplete-install
To uninstall autocomplete, run the nomad
command with the
-autocomplete-uninstall
option.
$ nomad -autocomplete-uninstall
Command contexts
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. For example, the nomad job run
command runs a new job and the nomad status
command queries information about existing jobs. Conversely,
commands with a prefix in their name likely operate in a different context.
Examples include the nomad agent-info
or nomad node drain
commands,
which operate in the agent or node contexts respectively.
Remote usage
You may use the Nomad CLI 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.
$ NOMAD_ADDR=https://remote-address:4646 nomad status
$ nomad status -address=https://remote-address:4646
The Nomad address must be reachable from your local machine. If the Nomad
port is exposed to the public internet, we recommend configuring TLS. Refer to
the tls
block in agent configuration for details.
Environment variables
Nomad can use environment variables to configure command-line tool options. You may override these environment variables with individual flags.
Connection environment variables
NOMAD_ADDR
- The address of the Nomad server. Defaults tohttp://127.0.0.1:4646
.NOMAD_REGION
- The region of the Nomad server to forward commands to. Defaults to the Agent's local regionNOMAD_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) information in environments where the Nomad API is behind an authenticating proxy server.
Access control list (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.
Mutual TLS (mTLS) environment variables
NOMAD_CLI_SHOW_HINTS
- Enables ui-hints in common CLI command output.NOMAD_CLIENT_CERT
- Path to a PEM encoded client certificate for TLS authentication to the Nomad server. Must also specifyNOMAD_CLIENT_KEY
.NOMAD_CLIENT_KEY
- Path to an unencrypted PEM encoded private key matching the client certificate fromNOMAD_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 bothNOMAD_CACERT
andNOMAD_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 license environment variables
NOMAD_LICENSE_PATH
- An absolute path to a Nomad Enterprise license file, for example/etc/nomad.d/license.hclic
.NOMAD_LICENSE
- The Nomad Enterprise license file contents as a string.