I want to get the current container’s instance number (the ‘1’ part of microservices-1, for example) when running multiple containers per service.
This is useful for instance when using something like shortid:
If you are running multiple server processes then you should make sure every one has a unique worker id. Should be an integer between 0 and 16. If you do not do this there is very little chance of two servers generating the same id, but it is theatrically possible if both are generated in the exact same second and are generating the same number of ids that second and a half-dozen random numbers are all exactly the same.
I can see this number on the end of the environment variable “MICROSERVICES_1_ENV_DOCKERCLOUD_CONTAINER_HOSTNAME” = “microservices-1”
But I can’t see the id on it’s own. Is it available anywhere?