Function as a Service for Docker

I missed DockerCon live for its closing sessions but I saw a tweet from Jerome mentioning Ben Firshman about “Serverless” Docker.

Serverless Docker

And I really don’t know what does “Severless” mean. So I dig around and found it’s the Function-as-a-Service model. I studied this model a while ago to POC a Map-Reduce model (similar to Apache Spark) based on Docker but I made no progress.

Back to the example. Ben’s example is written in Python but I’m not a Python guy so I started looking around again. Ben pointed to Ahment’s go-dexec.

I forked and tweaked it a bit to fit my need and came up with this FaaS wrapper generator. I no-brainer call it `faas`.

With `faas get` you can generate a function from an image on Docker hub. But before you can generate the wrapper, you need to put a signature for your image. In case of Ben’s leftpad example, I have this Dockerfile inherited from his. I built and tagged it as chanwit/leftpad.

FROM bfirsh/leftpad
LABEL signature=”(string, int) error”

Try to prepare your own :-)

Next step is to generate the wrapper. You can do:

$ faas get

to generate a wrapper. Replace this with your own image. Currently I wrote a simple argument type mapper to map string and int just to make the demo work.

Then in test.go, you can just write:

package main
import (
func main() {
err := chanwit.Leftpad(“foo”, 5)
if err != nil {

and run it with the command:

$ go run test.go

The program will trying to pull the image, spawn a container (on your cluster or node, depending on where you point DOCKER_HOST to), then run it. The current version of `faas` just prints something out. I’ll try to extend this and re-model the concept of Map-Reduce over it again. Hope it will be working this time. Pull requests are welcome!!

Check it out here: