Skip to content

The tiniest Docker image for testing HTTP services — just 23kB!

Notifications You must be signed in to change notification settings

kljensen/hello-world-http

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⚡ Tiny Hello World HTTP ⚡

The goal of this project is to be the smallest possible Docker image for testing HTTP services. The server responds to all HTTP requests with a simple "Hello, World!" As of v0.5.0, the Docker container is just 23kB.

Why?

Sometimes I want to test my backend setup: a reverse proxy, some port forwarding, my docker-compose configuration, etc. In such cases, I want the most simple HTTP service possible. This is it.

Running with Docker

To run this with Docker, do something like

docker run \
  -e HOST=0.0.0.0 -e PORT=8000 \
  -p 8000:8000 --init \
  ghcr.io/kljensen/hello-world-http:latest

Notice:

  • HOST and PORT are required.
  • HOST must be in dotted decimal, like 0.0.0.0
  • If HOST is something other than 0.0.0.0, your container will likely not respond to external requests.
  • PORT is the port on which the server will listen inside the container. If you're forwarding from the host to the container, obviously this needs to match the port you publish with -p. See the Docker documentation.
  • The --init flag is optional, but it's a good idea to use it. It ensures that the server process is stopped properly when Docker gets a SIGTERM signal. (For example, this will make docker run handle Ctrl-C properly.)

Running with Docker Compose

To run this with Docker Compose, you should have a docker-compose.yml file that looks something like

services:
  hello-world:
    image: ghcr.io/kljensen/hello-world-http:latest
    init: true
    ports:
      - "8000:8000"
    environment:
      - HOST=0.0.0.0
      - PORT=8000

Then you can run it with

docker-compose up

Past versions

Check out the packages and tags.

License

This is licensed under the Unlicense. Do whatever you want with it!

Related projects

About

The tiniest Docker image for testing HTTP services — just 23kB!

Resources

Stars

Watchers

Forks

Packages