I have some private catalog services set up and some of the containers that make up these services require the IP address of the host they are running on to be passed in as environment variables. Up to now, we have just set a label on a specific host and used the rancher scheduling to tell it to always start these containers on said host. However we would like to have them more dynamic and the ability to start them on multiple hosts.
I know its possible to modify the containers and have it pull the information from the rancher metadata service, but I would like to avoid modification of the containers if possible.
My next thought was to set an environment variable on all the hosts such as
HOST_IP and then load that from the docker-compose.yml or rancher-compose.yml file in the catalog entry. This doesn’t seem to work as they end up empty when starting the service.
So question 1: Where can I set those environment variables if at all to be picked up in the docker and rancher compose files when starting a container. I don’t seem to have a rancher compose container running anywhere which is how the official docs seem to say to do it.
The other thought I had was if it was possible to use a host label with the IP address when starting these catalog services. So question2: If I set a host label similar to
HOST_IP=123.321.456.654 can I then use that value in the catalog entry somehow, and if yes, how?
Thank you for any help.