Any way to specify a dynamic Environment Varible while scaling?


I have a service for collecting messages from its primary container(the logging service act as a sidekick). Eventually they will be aggregated together. In order to distinguish messages from different container, the message will be sent to different topics which topic_name is an environment variable specified in compose.yml file.

Any way to specify a dynamic environment variable while scaling?(such as node-1, node-2, node-3…)


Metadata for each container contains a unique create_index, among other possible alternatives like UUID:

Thanks vincent!

Both create_index and container’s name would be nice, but I still confused with the usage of metadata service.

Rancher Document shows metadata can be obtained by posting a http request inside container. And this article introduce a tool called confd also keeps me puzzled.

Considering non-invasive case, I hope the changes in Image/APP would be as little as possible.
So far, the only solution I can think of is making a starting script such as ‘export XX=`curl http://rancher-metadata/2015-07-25/self/container/create_index`’ then use such enviroment varible while rancher-compose up.

Any simpler way to get metadata while container launching a service(better in compose.yml)?

I’m looking for the same thing. Ideally I’d like to be able to access the metadata as environment variables from within the running container. I’d like to use this to display the index in my web app’s UI to help us with load balancing issues.

@jarroda We currently do not support accessing the metadata as environment variables as it would be duplicating the metadata information.