Passing Hostname or Environmental Variables into Docker Container from Marathon / Deimos?

1,970 views
Skip to first unread message

Patrick White

unread,
Jul 24, 2014, 8:40:09 PM7/24/14
to marathon-...@googlegroups.com
Hi Everyone,
Quick question - is it possible to pass in either a hostname or an environmental variable from deimos (running marathon .6 on mesos .19)? In the marathon application definition json I tried specifying:

"env": {
  "HOSTNAME"="$HOSTNAME"
}

As well as a few variants of that.

Looking at the deimos code, I thought that might work, but it seems to be just passing in the actual text. Any way I could get a pointer back to the host passed in? Basically, I'm using consul.io and have consul running on each of the slaves, so passing that in would give me a first point to do service discovery. There are obviously work arounds, but I like this method, would be great if there was a way to get it working.

Thanks!
-PW

Michael Hamrah

unread,
Jul 25, 2014, 8:06:53 AM7/25/14
to marathon-...@googlegroups.com
Yes, you can update the Deimos.cfg file to inject environment variables. See here: http://blog.michaelhamrah.com/2014/06/service-discovery-options-with-marathon-and-deimos/ and the Deimos readme,

Patrick White

unread,
Jul 25, 2014, 12:41:29 PM7/25/14
to Michael Hamrah, marathon-...@googlegroups.com
Thanks Michael, this is exactly what I was looking for. And, thanks for all the great articles, we're scala / akka and moving to mesos / marathon, so it's been great having your blog as a resource!


On Fri, Jul 25, 2014 at 5:06 AM, Michael Hamrah <mha...@gmail.com> wrote:
Yes, you can update the Deimos.cfg file to inject environment variables. See here: http://blog.michaelhamrah.com/2014/06/service-discovery-options-with-marathon-and-deimos/ and the Deimos readme,

--
You received this message because you are subscribed to a topic in the Google Groups "marathon-framework" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/marathon-framework/wFQMkN3HeZ4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to marathon-framew...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Patrick White

Synata | Chief Executive Officer


pat....@synata.com

www.synata.com

831.601.9288

Michael Hamrah

unread,
Jul 25, 2014, 12:48:29 PM7/25/14
to Patrick White, marathon-...@googlegroups.com
Cool, glad you like the articles! I actually wrote those because I was experimenting with consul for service discovery as well, but never got to the consul part. I envisioned consul running on the masters, not slaves, with docker containers registering their slave's ip addresses for service discovery. Consul's dns approach also looked interesting- curious to know how you fare. Hopefully will have time this weekend to experiment.

Mike

Patrick White

unread,
Jul 25, 2014, 12:55:53 PM7/25/14
to Michael Hamrah, marathon-...@googlegroups.com
Consul is great, I saw that keen.io wrote a patch for marathon that integrates with it, hoping that gets pulled into the next release. Basically, the way I *think* they designed consul to run is for every host to have an agent running, then the mesos masters would have the consul servers. So, from any host you could basically DNS / HTTP against localhost for lookup. Obviously with docker that becomes an issue - I was playing with the idea of having consul running in my container, but I couldn't find a clean hook that I could use for the consul agent to gracefully leave when the container shuts down (though, I'm new to Docker, I might have missed something). Hardest part with scala is getting a good scala / java based reactive DNS client (I ended up just using Consul's HTTP interface).

Good luck!
-PW
Reply all
Reply to author
Forward
0 new messages