Setup a Basic Website with Apache HTTPD in Docker

A quick and simple way to setup a basic website using Apache HTTPd with Docker. 🐳

Setup a Basic Website with Apache HTTPD  in Docker

Sometimes keeping things simple is better. This can be especially true when it comes to documentation type websites. Today we will use the Apache HTTPD Docker image to quickly get you up and running with a basic HTML website.

What is Apache HTTPD?

Apache HTTPD is an open source HTTPserverdaemon produced by the Apache Foundation. It is a piece of software that listens for network requests (which are expressed using the Hypertext Transfer Protocol) and responds to them.

For this demonstration I will be using Apache HTTPD to serve up the free documentation website Simply-Docs.

Simply-Docs is a static documentation website using only HTML and CSS for styling and is the perfect example to use with Apache HTTPD. Simply drop the files in your HTTPD mounted directory and away you go!

Installing Apache HTTPD with Docker Compose

We will be using the official Apache HTTPD Docker image that can be seen here. All I did was convert it from a Docker run command to a usable Docker Compose file.

version: '3.3'
services:
    httpd:
        container_name: my-apache-app
        ports:
            - '8080:80'
        volumes:
            - '/apache:/usr/local/apache2/htdocs/'
        image: 'httpd:latest'
        restart: always
    filebrowser:
        container_name: filebrowser
        ports:
            - 8081:8080
        volumes:
            - /apache:/data
            - /docker/filebrowser:/config
        environment:
            - FB_BASEURL=/f
        image: hurlenko/filebrowser
        restart: always

I also added Filebrowser into the stack so we can easily upload and edit our files.

The Filebrowser data volume is mapped to the same data volume where the files will be located for HTTPD. This way when you are done installing the stack it's turn key and all you have to do is log into Filebrowser on port 8081 with the username and password of admin:admin and begin adding your files.

Using Filebrowser, all we have to do is drop the files in to upload them then visit our website on port 8080 where Apache HTTPD is listening.

You can see how effective Filebrowser can be in situations like this when you want to modify free templates like Simply-Docs. It's very handy and makes editing the template much quicker.

Apache HTTPD is a very lightweight container clocking in at only 8.7 mb of RAM usage and little to no CPU usage when idle. Filebrowser is even lower at 7.1mb of RAM so you can see how this would be a great solution to run on a Raspberry Pi.

Final Notes and Thoughts

There you have it. The quick and painless way to get a simple HTML website hosted using Docker.

This can work with any HTML based website or template. Startboostrap has tons of templates you can also choose from that are also free for non commercial use!