Search code examples
restdockermesosmarathon

How to scale up docker instances using Apache Marathon REST API.?


Is it possible to scale up and down number of docker containers/instances using Mesosphere Marathon REST API?

Endpoint GET /deployments seems to be only option to see the next possible operation. How to scale up the instances using REST API (programmatically: possibly using curl script and without using the Marathon Web interface)?


Solution

  • You should use PUT with JSON with only field "instances" with desired instances count (e.g., 2) and application ID (e.g., /foo).

    PUT <marathon-url>/v2/apps/foo
    
    { "id": "/foo", "instances": 2 }
    

    Note: Marathon 1.4 deprecates PUT semantic.

    A PUT on /v2/apps has a PATCH like semantic: All values that are not defined in the json, will not update existing values. This was always the default behaviour in Marathon versions. For backward compatibility, we will not change this behaviour, but let users opt in for a proper PUT. The next version of Marathon will use PATCH and PUT as two separate actions.