10

I'm working with mesos + marathon + docker quite a while but I got stuck at some point. At the moment I try to deal with persistent container and I tried to play around with the "volumes-from" parameter but I can't make it work because I have no clue how I can figure out the name of the data box to put it as a key in the json. I tried it with the example from here

    {
    "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
}

I would really appreciate any kind of help :-)

hammi
  • 161
  • 1
  • 8
  • I'm not exactly clear on how this is a Marathon or Mesos problem but I'll ask you the obvious—did you read https://docs.docker.com/userguide/dockervolumes/ already? The value for another-container is simply the container ID of the container you want the volumes mounted/shared from—note that at least one container needs to use a volumes otherwise it's gone and that volumes live on the host, in special directories, so that they can be shared between containers. What's your use case, BTW? – Michael Hausenblas Mar 16 '15 at 03:52
  • 1
    thanks for the answer and yes I did read it. my problem is that I don't know how to get the ID or the set name of the container with the data. my use case is pretty simple, I have an application container running and this one has to access data which I want to get out of a data only container. If I absolutely can't figure out how to deal with the volumes-from option I have to fall back and put the data on the host and mount that from there because that I know how to address. – hammi Mar 16 '15 at 09:35
  • He he that was not an answer (yet) just clarification. Can you share more about your setup pls? – Michael Hausenblas Mar 16 '15 at 12:49
  • 1
    It seems to be a similar issue: http://stackoverflow.com/questions/28681235/how-know-container-name-with-marathon-rest-api but I don't understand how the answer solves the unknown name issue. – Céline Aussourd Mar 16 '15 at 17:55
  • yes that is the same issue and the answer doesn't fix it. Before I opened this question I tried to reopen this one but my question got deleted. – hammi Mar 18 '15 at 13:53
  • yes what can I say, I still couldn't make it work and ended up with an workaround. but if anybody has an idea how it works I would gladly hear about it :) – hammi Apr 07 '15 at 08:03
  • did you try http://blog.emccode.com/2015/08/28/run-your-stateful-apps-with-mesos-and-docker/ – Dimitri Kopriwa Dec 07 '15 at 14:11

4 Answers4

1

From what I know : docker --volume-from take the ID or the name of a container.

Since your datacontainer is launch with Marathon too, it get an ID (not sur how to get this ID from marathon) and a name of that form : mesos-0fb2e432-7330-4bfe-bbce-4f77cf382bb4 which is not related to task ID in Mesos nor docker ID.

The solution would be to write something like this for your web-ubuntu application :

"parameters": [
    { "key": "volumes-from", "value": "mesos-0fb2e432-7330-4bfe-bbce-4f77cf382bb4" }
]

Since this docker-ID is unknown from Marathon it is not practical to use datacontainer that are started with Marathon.

You can try to start a datacontainer directly with Docker (without using Marathon) and use it as you do before but since you don't know in advance where web-ubuntu will be scheduled (unless you add a constraint to force it) it is not practical.

tgermain
  • 31
  • 1
  • 5
  • the name look like `mesos-d5e25559-7af4-4816-8dbb-ace444c0ccfa-S1.34d5b1c0-3e00-1411-88b9-b709cedc8ddd`, the first part can be retrived in marathon at `https://marathon.domain.com/v2/tasks` at `task.slaveId`. I haven't found where to get the last part. Did you ? – Dimitri Kopriwa Dec 07 '15 at 13:48
0

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

Something like that maybe?

aholt
  • 2,455
  • 1
  • 8
  • 13
  • I have tried what you suggested but it is still the same problem. when I run the deployment I get the following error back: "exit status = exited with status 1 stderr = time="2015-03-18T10:20:00Z" level="fatal" msg="Error response from daemon: container databox not found, impossible to mount its volumes"" I still have the problem that I can't figure out the name or id of the container with the persistent data to tell the webapp where to find it. – hammi Mar 18 '15 at 10:21
0

Mesos support passing the parameter of volume plugin using "key" & "value". But the issue is how to pass the volume name which Mesos expects to be either an absolute path or if absolute path is not passed then it will merge the name provided with the slave container sandbox folder. They do that primarily to support checkpointing, in case slave goes down accidentally.

The only option, till the above get enhanced, is to use another key value pair parameter. For e.g. in above case

{ "key": "volumes-from", "value": "databox" }, { "key": "volume", "value": "datebox_volume" }

I have tested above with a plugin and it works.

-1

Another approach is to write a custom mesos framework capable of running the docker command you want. In order to know what offers to accept and where to place each task you can use marathon information from: /apps/v2/ (under tasks key).

A good starting point for writing a new mesos framework is: https://github.com/mesosphere/RENDLER

Radu Cosnita
  • 130
  • 1
  • 4
  • You might also want to use the newly added pods capability: https://mesosphere.github.io/marathon/docs/pods.html. You will be able to share volumes between containers. – Radu Cosnita Apr 22 '17 at 21:52