consul
service discovery and configuration tool
TLDR
Start agent in development mode
$ consul agent -dev
List datacenter members$ consul members
Register service$ consul services register [service.json]
Deregister service$ consul services deregister -id=[service-id]
List services in catalog$ consul catalog services
DNS lookup for service$ dig @127.0.0.1 -p 8600 [web].service.consul
Store key-value pair$ consul kv put [key] [value]
Get key-value$ consul kv get [key]
Join cluster$ consul join [192.168.1.100]
SYNOPSIS
consul [options] command [arguments]
DESCRIPTION
consul is HashiCorp's service discovery and configuration tool. It provides service mesh, health checking, key/value storage, multi-datacenter support, and secure service-to-service communication.
PARAMETERS
-dev
Development mode (single node, no persistence)-token token
ACL token for authentication-datacenter dc
Target datacenter-http-addr addr
Consul HTTP API address
CONFIGURATION
/etc/consul.d/
Configuration directory for Consul agent settings, services, and checks in HCL or JSON format.
COMMANDS
agent
Run a Consul agentmembers
List cluster membersjoin
Join cluster via agent addressleave
Gracefully leave clustercatalog
Interact with service catalogservices
Register/deregister serviceskv
Key/value store operationsconnect
Service mesh functionalityacl
Access control list managementsnapshot
Save/restore cluster statedebug
Create debugging archive
ENVIRONMENT
CONSUL_HTTP_ADDR
HTTP API addressCONSUL_HTTP_TOKEN
ACL tokenCONSUL_CACERT
CA certificate path
DNS INTERFACE
Default DNS port: 8600
$ dig @127.0.0.1 -p 8600 web.service.consul
CAVEATS
ACL system requires token for most operations when enabled. Development mode stores everything in memory. Production requires proper clustering configuration.
