Skip to Content

Fibonacci with an interconnected network of Docker containers

On Monday, I posted a tutorial on how to compute fibonacci numbers with a recursive algorithm that spawns Docker containers inside docker containers.

Yes. Here’s the project to do that: Fiboweb

this version of Fibonacci uses Docker to spawn web servers that communicate one with the others.

Each web server knows the value of the Nth Fibonacci number. To know this value, it has to connect to the web server that knows N-2 and the web server that knows N-1.

Our script takes N as a parameter and spawns N docker daemons. Each docker container except #0 and #1 is linked to two other docker containers so that it can query them on their port 8000 with wget.

The last docker container maps its 8000 port to the host so that it can be queried.

FROM google/debian:wheezy
comments powered by Disqus