registrator
registrator copied to clipboard
-envFile option to read variables from within container at runtime
I need to change Consul service description from inside container by custom application logic. This patch allow this by specifying -envFile
option to registrator which is the file path inside containers. Registrator try reads this file at runtime from each container instance and use as another source of configuration like Labels or ENV but with highest priority.
Examples: File /tmp/dynamic_envs inside test_container
SERVICE_NAME=my_new_service_name
SERVICE_TAGS=tag1,tag2
SERVICE_ANOTHER=custom_metadata_value
Registrator launch:
./registrator -ip 172.99.1.1 -cleanup -ttl 40 -ttl-refresh 10 -resync 60 -envFile /tmp/dynamic_envs consul://172.99.1.1:8500
Dynamic changes:
docker exec -it test_container /bin/sh -c "echo SERVICE_META=123 >> /tmp/dynamic_envs"
After refresh interval(10s) new metadata with name meta and value 123 appear in already registered consul service.
What do you think?