Containerization and Docker, in particular, are getting a lot of traction these days. We heard about the potential, the stability, density, scalability it provides running applications.

Another great potential is that we can run nearly any technology, stack, distributed systems, from the comfort of our laptop (ofC, with several limitations, but we can build PoC with a certain degree of quality).

Recently I was traveling with just a small 4GB laptop with limited disk space and wanted to play around with some stuff in NodeJS in the free time. I didn’t want to install it because as its not my main working computer I would simply live there gaining dust and consuming resources. I just wanted to click a button, enjoy the technology, and remove it in the end.

And Docker came to the rescue, I built a tiny image with only 30MB (!) with Node and a small http-server used mainly for prototyping. I am so happy with it that I decided to share to the world here.

If you need to to build a small app and don’t want to install Node on your machine for whatever reason, this is a good setup. Uses ZZROTDesign/alpine-node and indexzero/http-server.

Usage

Pull and navigate to this repo directory and build the image (probably should add the image on Docker Hub to avoid this step):

docker build -t tmds/node-http-server .

Navigate to your app directory and start the server (daemon mode):

docker run -v $(pwd):/home/app -p 8080:8080 -d tmds/node-http-server http-server

And now the magic happens. Just can start another container to play with node as if it was installed on your machine:

docker run -v $(pwd):/home/app -it --rm tmds/node-http-server /bin/ash

And now an interactive shell should be ready to play, to run commands or node applications. The http-server also should be running, on your docker machine IP at port 8080.

Feedback is appreciated :)