Open ProbablyRusty opened 10 years ago
I started to log a new issue, but instead I will bump as I believe this is the same thing:
If I run a container and specify container metadata like this: (my docker host machine is named dockerhost)
$ docker run -d --name redis.0 -p 10000:6379 \
-e "SERVICE_NAME=db" \
-e "SERVICE_TAGS=master,backups" \
-e "SERVICE_REGION=us2" \
-e "SERVICE_CHECK_TTL=30s" dockerfile/redis
Then the resulting CheckID is service:dockerhost:redis.0:6379
However from inside the container there is not an easy way to deduce this checkname.
I might be able to pull it together by querying the docker unix socket the same way registrator pulls information for the container to get the container's name and then query the consul service directly for the serviceID, then query consul for all health checks and filter based on the SerivceID. But this seems odd to do in the container when registrator might have this endpoint available somewhere.
I understand that I could use the out of band http and script checks on progrium/consul to accomplish a health check in the reverse direction, but I was hoping to have a more tightly coupled check in some instances where I have a dead man switch that calls out the http endpoint.
Could registrator set an environment variable or some other mechanism for communicating the health check url?
I'd like to be able to implement Consul TTL health checks when running containers, by specifying
SERVICE_CHECK_TTL=30s
at runtime, but I am wondering if there is a straightforward way for the container to be aware of thecheckId
for its particular registration, so that, inside the container, I can implement a passing/v1/agent/check/pass/<checkId>
call to the Consul API (upstream, Consul agent is not running in the container) to affirm health for the container.