A simple echo service

with tags container echo -

For some testing, I needed a simple HTTP server which would print headers that my client is sending (and some headers added by my proxy). I had written a simple HTTP server in python which did exactly what I wanted, and added it to python container from dockerhub.

It was ridiculously large at ~260MB. Even the slim variants of python containers were ~75MB.

So, thought to write the same in Go (for fun, and result of single static binary), and just add it to busybox container. Result was a tiny ~5MB container as busybox base itself is tiny (<1MB) set of tools, and nothing else. One can even use scratch instead of busybox as basecontainer when the binary is not dependent on anything like this go binary.

Here is the code I wrote for this which is self explanatory.

Lesson I learned from this experience is that its good to use busybox as base for adding go based utils. Others seem to be doing same for the simpler utilities.

Written by karteek

Older article