1

I have an application that deploys through Marathon multiple similar servers (containerized in Docker containers), using Marathon auto-assigning 'port' feature. That is nice and excatly the way I need in my app.

The problem is that my servers deployed in Marathon (PyWPS servers) are using code that does not fit really well with modern distributed architecture. PyWPS requests to define into a static config file, the IP and Port for the polling from the client apps.

When I have static IP/ports on my containers, it is easy to run a script (inside the container) at the launch of the container that 'sed' the config file to put the right IP/port values from a ENVVAR that I set in the container starting command line.

The problem arise when it comes to use undeterministic dynamic IP/port. Is there a way to catch these info in the container when it is deployed by Marathon, as a kind of event "container_start" hook ?

matt
  • 1,046
  • 1
  • 13
  • 26

1 Answers1

2

If I understand you correctly, this should be easily solvable in a similar way as you described.

For example, if you run your app with HOST networking and a random port (by specifying "ports": [0] for example), then Marathon will set the $HOST and $PORT0 environment variables. You don't need to set something similar in a manual way.

Then, have your entrypoint script manipulate the configuration based on these two environment variables, and you should have a fully dynamic ip/port setting.

Tobi
  • 31,405
  • 8
  • 58
  • 90
  • Thank you Tobi for your anwser. I finally patched my servers code since it was more straightforward in my case. but your solution would work as well. – matt Oct 18 '16 at 15:41
  • @matt Can you explain a bit? In what way did you apply the patch? – Tobi Oct 18 '16 at 16:42
  • [Here](http://gis.stackexchange.com/questions/214454/dynamic-ips-for-polling-and-results-requests-using-pywps) is the way I've patched PyWPS in order to get the wanted behaviour – matt Oct 18 '16 at 17:18