Hastatic: A tiny static content web server for Docker

・1 min read

I wrote this teeny-tiny static content web server for Docker. Just use it as the base image to add your website content and you get a Docker image of your website with a server baked in! And it's choked full of features too.

Check it out:

abhin4v / hastatic

hastatic is a tiny static content web server for Docker


Docker Build Status Docker Pulls MicroBadger Size

hastatic is a very small web server for serving static files from a Docker container.


  • A lightweight web server, just 5 MB in size.
  • Statically compiled binary with no dependencies.
  • Built for Docker.
  • Supports HTTPS.
  • Supports custom 404 file.
  • Supports custom index files for URLs ending with "/".
  • Takes care to not serve hidden files.
  • Adds caching headers automatically.
  • Adds security headers automatically.
  • Caches file descriptors and info for better performance.


Create a Dockerfile for your website, deriving from abhin4v/hastatic:

FROM abhin4v/hastatic:latest
COPY mywebsite /opt/mywebsite
WORKDIR /opt/mywebsite
CMD ["/usr/bin/hastatic"]

Build and run:

$ docker build -t mywebsite .
$ # run with default configs
$ docker run -p 8080:3000 mywebsite
$ # run with custom configs
$ docker run -e PORT=2000 -e NF_FILE=404.html -e IDX_FILE=index.html -p 8080:2000 mywebsite
$ # run with HTTPS support
$ docker run -e TLS_CERT_FILE=certificate.pem -e TLS_KEY_FILE=key.pem -p 443:3000

That's awesome. What inspired you to work on this?


I wanted to self-host my website on Docker and the existing static content web servers didn't have the functionalities I needed. So I wrote my own!

Classic DEV Post from Feb 5

Overcoming the Tutorial Gap and Making Your Own Software

How to take the next step in the software development journey.

Amateur Category Theory Enthusiast

Hey there reader...

Do you prefer sans serif over serif?

You can change your font preferences in the "misc" section of your settings. ❤️