Search code examples
dockermesosmesospheremarathon

how know container name with marathon rest API


I'm using Apache Mesos + Marathon + Zookeeper to deploy my rails app. I need share data between rails app and other container. I found some reference here to do it with marathon as follow:

marathon/docs/native-docker.html

{
"id": "privileged-job",
"container": {
    "docker": {
        "image": "mesosphere/inky"
        "privileged": true,
        "parameters": [
            { "key": "hostname", "value": "a.corp.org" },
            { "key": "volumes-from", "value": "another-container" },
            { "key": "lxc-conf", "value": "..." }
        ]
    },
    "type": "DOCKER",
    "volumes": []
},
"args": ["hello"],
"cpus": 0.2,
"mem": 32.0,
"instances": 1
}

But I can't found a way to discover a name of my rails app container because marathon assign names with format: "mesos-uuid". Any idea to solve it? or another way to share volume from containers with marathon?


Solution

  • You can add constraints to your app to force them onto specific hosts.

    In a simple case, you could do something like this to force an app onto a specific host:

    {
     "instances": 1,
     "constraints": [["hostname", "LIKE", "worker-1"]]
    }
    

    The next option brings in attributes. You can tag a known number of hosts (let's say 3) with some custom tag.

    Then your app definition could look like this:

    {
     "instances": 3,
     "constraints": [
       ["hostname", "UNIQUE"],
       ["your-custom-tag", "GROUP_BY"]
     ]
    }
    

    You'd add this to the app definition for both of your apps, resulting in one instance of each running on all three slaves you tagged.

    See the a reference doc on setting attributes.