Registrator is designed to be run once on every host. You could run a single Registrator for your cluster, but you get better scaling properties and easier configuration by ensuring Registrator runs on every host. Assuming some level of automation, running everywhere is ironically simpler than running once somewhere.
docker run [docker options] gliderlabs/registrator[:tag] [options] <registry uri>
Registrator requires and recommends some Docker options, has its own set of options and then requires a Registry URI. Here is a typical way to run Registrator:
$ docker run -d \ --name=registrator \ --net=host \ --volume=/var/run/docker.sock:/tmp/docker.sock \ gliderlabs/registrator:latest \ consul://localhost:8500
||yes||Allows Registrator to access Docker API|
||recommended||Helps Registrator get host-level IP and hostname|
An alternative to host network mode would be to set the container hostname to the host
-h $HOSTNAME) and using the
-ip Registrator option below.
||v7||Cleanup dangling services|
||v6||Deregister exited services "always" or "on-success". Default: always|
||Use exposed ports instead of published ports|
||Force IP address used for registering services|
||v6||Frequency all services are resynchronized. Default: 0, never|
||v7||Max retry attempts to establish a connection with the backend|
||v7||Interval (in millisecond) between retry-attempts|
||v5||Force comma-separated tags on all registered services|
||TTL for services. Default: 0, no expiry (supported backends only)|
||Frequency service TTLs are refreshed (supported backends only)|
||Uses the IP address stored in the given label, which is assigned to a container, for registration with Consul|
-internal option is used, Registrator will register the docker0
internal IP and port instead of the host mapped ones.
By default, when registering a service, Registrator will assign the service
address by attempting to resolve the current hostname. If you would like to
force the service address to be a specific address, you can specify the
For registry backends that support TTL expiry, Registrator can both set and
refresh service TTLs with
If you want unlimited retry-attempts use
-resync options controls how often Registrator will query Docker for all
containers and reregister all services. This allows Registrator and the service
registry to get back in sync if they fall out of sync. Use this option with caution
as it will notify all the watches you may have registered on your services, and
may rapidly flood your system (e.g. consul-template makes extensive use of watches).
Consul ACL token
If consul is configured to require an ACL token, Registrator needs to know about it, or you will see warnings in the consul docker container
[WARN] consul.catalog: Register of service 'redis' on 'hostname' denied due to ACLs
The ACL token is passed in through docker in an environment variable called
$ docker run -d \ --name=registrator \ --net=host \ --volume=/var/run/docker.sock:/tmp/docker.sock \ -e CONSUL_HTTP_TOKEN=<your acl token> \ gliderlabs/registrator:latest \ consul://localhost:8500
The registry backend to use is defined by a URI. The scheme is the supported registry name. The address is a host or host and port used to connect to the registry. Some registries support a path definition used, for example, as the prefix to use in service definitions for key-value based registries.
For full reference of supported backends, see Registry Backends.