Sign inSign up

jdkelley/simple-http-server

By jdkelley

•Updated almost 7 years ago

Image
1

100K+

jdkelley/simple-http-server repository overview

⁠simple-http-server

I get asked, "how can I serve the files I have locally?" A ready answer to this is to use Python's SimpleHTTPServer⁠ (now with Python 3, this is http.server⁠). This question, however, is often from individuals who will have Docker installed but don't necessarily want to dig into the details of specific python versions or writing a Dockerfile. The goal of this project is to give a single command with no extra dependencies that will serve the directory you point it at.

WARNING: DO NOT run this in production. This is purely a convenience tool.

⁠Using

To serve files, stand the server up with this docker command. Make sure you map (as a volume with /serve) the directory you wish to serve:

docker run --rm \
    -v <directory-to-serve>:/serve \
    -p 80:8000 \
    jdkelley/simple-http-server:latest

To serve your current directory, use:

docker run --rm \
    -v $(pwd):/serve \
    -p 80:8000 \
    jdkelley/simple-http-server:latest

I find it useful to add a bash function to my profile to avoid typing that all out:

simple-http-server() {
    docker run --rm \
        -v $(pwd):/serve \
        -p 80:8000 \
        jdkelley/simple-http-server:latest
}

And then use it with simple-http-server. You can find an example of the function I use in example/bash_functions.sh⁠.

⁠Building from source

docker build -t http-server:latest .

To run this generated image and serve your current directory, run docker run $(pwd):/serve -p 80:8000 http-server:latest.

⁠Deployed

This is deployed on GitHub Package Registry⁠ and Docker Hub⁠.

The source can be found on GitHub.⁠

Tag summary

Content type

Image

Digest

Size

19.4 MB

Last updated

almost 7 years ago

docker pull jdkelley/simple-http-server