Runtime Confusion


In API.ServiceSpec.Task.Spec.Runtime you can set a string to define the Runtime used for a task. However, I can only find a single (non-test) reference to Spec.Runtime in swarmkit/agent/exec/dockerapi/container.go, and it sets it, not calls it. I am trying to write a raw exec/cmd line executor to automate backend system tasks along with containers in a Service, like how Nomad does it, but I’m completely lost where the Scheduler passes a task onto an Agent. I don’t see any slices of Executors; are the Executors mutually exclusive to one another on each Node? Or does a Node run several Agents, one for each Executor? It doesn’t make a whole lot of sense to have Runtime selectable at the Task level if it cannot be selected at the Node; am I reading things wrong?


The way to do this would be to use the Generic runtime and add an implementation in the swarmkit caller to deal with that.

Here is an example:
This is the validation code from the Docker API for generic runtimes.
Note there is no code change required to pass in whatever runtime you want.
What should happen is the node agent should have an implementation that can handle the specified runtime.

Docker itself has implements a “plugin” runtime for scheduling plugins across the swarm using services. The agent implementation starts here:

So basically there’s two parts, the Docker HTTP API which converts the json service create request into a swarmkit service create request, swarmkit schedules a task for the service to a node and the executor on that node handles it as needed.