Swarm makes it incredibly easy to run code on your infrastructure. You wrap some code up inside a Docker container, and Swarm will make it run on whatever free resources you have.
But what if those containers could also run other containers on a Swarm? We could put pieces of our application inside containers that are run on-demand on a Swarm. Docker containers can be used as functions from within other applications:
>>> import dockerrun >>> client = dockerrun.from_env() >>> client.run("bfirsh/leftpad", ["foo", "5"]) ' foo\n'
Take, for example, running background tasks in a web app. In a traditional architecture, you would have a set of task workers and a message queue to pass work from the web frontends to the task workers.
If your web frontends have access to a Swarm, you can run the task directly on your Swarm:
To read more about this, check out this blog post.
- Serverless voting app – A serverless web app
- go-dexec examples
- Funker – an example app that uses Funker to do processing in the background
- Introducing dexec – What if the Go os/exec library could containerize?
## Client libraries
- docker-py – Run Docker containers from Python apps
- dockerrun – A simpler interface for running Docker containers in Python (soon to be part of docker-py)
- go-dexec – Like Go os/exec package but for Docker
- dockerode – Run Docker containers from Node.js apps
- docker-java – Run Docker containers from Java apps
Stuff that needs working on
We need your help!
- Make this work with Docker 1.12.
- A proxy that scopes a Docker API so that containers can securely manage and run "child" containers.
- Helpers for injecting the Docker API socket into containers that are run.
- A server for running scheduled / cron jobs as Docker containers on a Swarm.