mesosphere / marathon

Deploy and manage containers (including Docker) on top of Apache Mesos at scale.
https://mesosphere.github.io/marathon/
Apache License 2.0
4.07k stars 844 forks source link

how to use docker_volume? #6794

Closed f1-outsourcing closed 5 years ago

f1-outsourcing commented 5 years ago

How to use the docker_volume with the mesos containerizer?

This executes, and mounts the external volume in the correct location.

mesos-execute --master=192.168.10.151:5050 --name=test --docker_image=influxdb --command="ls -lRrt /*" --volumes=file:///root/volume-test3.json

`
[@m03 ~]# cat volume-test3.json
[
  {
    "container_path":"/var/lib/influxdb",
    "mode":"RW",
    "source":
    {
      "docker_volume":
        {
          "driver": "rexray",
          "name": "app-influxdb"
        },
      "type": "DOCKER_VOLUME"
    }
  }
]

This works also

{
  "id": "influxdb",
  "cpus": 0.5,
  "mem": 128,
  "instances": 1,
  "acceptedResourceRoles": ["*"],
  "residency": { "taskLostBehavior": "WAIT_FOREVER" },
  "container": {
    "type": "MESOS",
    "docker": {
      "image": "influxdb",
      "credential": null,
      "forcePullImage": false
    }

  }   
}

This complains : There was a problem with your configuration

containerVolumes/0/containerPath: 'containerPath' is undefined on object: {"container_path":"/var/lib/influxdb","mode":"RW","source":{"docker_volume":{"driver":"rexray","name":"app-influxdb"},"type":"DOCKER_VOLUME"}}
containerVolumes/0/hostPath: 'hostPath' is undefined on object: {"container_path":"/var/lib/influxdb","mode":"RW","source":{"docker_volume":{"driver":"rexray","name":"app-influxdb"},"type":"DOCKER_VOLUME"}}
{
  "id": "influxdb",
  "cpus": 0.5,
  "mem": 128,
  "instances": 1,
  "acceptedResourceRoles": ["*"],
  "residency": { "taskLostBehavior": "WAIT_FOREVER" },
  "container": {
    "type": "MESOS",
    "docker": {
      "image": "influxdb",
      "credential": null,
      "forcePullImage": false
    },
    "volumes": [
  {
    "container_path":"/var/lib/influxdb",
    "mode":"RW",
    "source":
    {
      "docker_volume":
        {
          "driver": "rexray",
          "name": "app-influxdb"
        },
      "type": "DOCKER_VOLUME"
    }
  }
]

  }

}

http://mesos.apache.org/documentation/latest/isolators/docker-volume/#volume-protobuf

alenkacz commented 5 years ago

@f1-outsourcing you have container_path while it should be containerPath. Also hostPath is a mandatory field as well. Feel free to check out the docs https://mesosphere.github.io/marathon/docs/persistent-volumes.html

If you have more questions, please reach out on Mesos slack or create a JIRA. Thank you!