Closed lhenry7 closed 6 years ago
This example is working on my machine:
// Load docker etc etc
const scale = (service, replicas) => {
const data = service.data.Spec
data.version = service.data.Version.Index
data.Mode.Replicated.Replicas = replicas
return service.update(data)
}
scale(yourServiceObject, 5)
Thanks @herlon214, I see why your code works. Not being a native JS programmer was tripping me up!
Hi, trying to understand how to use this method? The docker api needs version in query string and Spec in Post body. Do you have any examples? I'm not a native js programmer and I'm not sure how I should be calling: var version = service.data["Version"]["Index"]; service.data.Spec.Mode.Replicated.Replicas=update_count; service.update({version: version}) .catch(error => console.log(error));
gives { Error: (HTTP code 400) unexpected - rpc error: code = InvalidArgument desc = TaskSpec: missing runtime at /etc/chef/compose-stacks/node_modules/docker-modem/lib/modem.js:239:17 at getCause (/etc/chef/compose-stacks/node_modules/docker-modem/lib/modem.js:269:7) at Modem.buildPayload (/etc/chef/compose-stacks/node_modules/docker-modem/lib/modem.js:238:5) at IncomingMessage. (/etc/chef/compose-stacks/node_modules/docker-modem/lib/modem.js:214:14)
at emitNone (events.js:111:20)
at IncomingMessage.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1055:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
reason: undefined,
statusCode: 400,
json:
{ message: 'rpc error: code = InvalidArgument desc = TaskSpec: missing runtime' } }
P.S. - Just saw this, seems related: (https://github.com/docker-java/docker-java/issues/958) does the api version need to be updated someplace?