3 ms·
A small enhancement to your HOST_IP grepping, the host's public and private IP is available in /etc/environment. docker0 may or may not be present before a dock
by bacongobbler 12y ago
A small enhancement to your HOST_IP grepping, the host's public and private IP is available in /etc/environment. docker0 may or may not be present before a docker run as well due to socket activation, so your results may vary with a brand new CoreOS VM where docker has not started yet. For example, we are resolving this in Deis with https://github.com/deis/deis/pull/851 https://github.com/deis/deis/pull/851
- marceldegraaf 12y agoHa, thanks! I actually got the grepping magic from Deis as well, but this is a much more elegant solution. By the way, Deis is looking really good now that it's CoreOS based :-).
- robszumski 12y agoTo expand on this a bit, you can source a file to expose variables to your unit. On most providers, CoreOS populates /etc/environment with the public and private IP. You can then use those as env vars in your unit: [Service] EnvironmentFile=/etc/environment You can then use $COREOS_PUBLIC_IPV4 anywhere in that unit file. Makes service registration a breeze.
- marceldegraaf 12y agoHi Rob, thanks for your expansion on it :-). I see Deis does that in a similar fashion. I'll update the article with this approach, because it's clearly the best way to solve the "host IP issue".