Public Repository

Last pushed: a year ago
Short Description
A naive HTTP Server container that echoes its hostname
Full Description

v0.5:

  • support health check endpoint

v0.4:

  • make echo message controllable via environment variable

v0.3:

  • expose port in Dockerfile
  • log each request to stdout

v0.2:

  • add return line at the end of message

v0.1:

  • first version, just echoes hostname

whoami

A naive docker image with a http server that echos hostname(identifies itself).

This docker image can be used to demostrate and validate load balance ability of your service.

Usage

$ docker run -d --name echo -p 80:8778 cizixs/whoami
$ curl http://127.0.0.1
2c47ad631c82
By default container exposes port 8778, and returns container hostname(short id) as response.

You can control what is returned by setting MESSAGE environment variable(the following example is illustrated under docker 1.12 swarm mode):

➜ docker service create -e MESSAGE="viola" -p 8778:8778 --replicas=2 whoami:v0.4
➜ curl http://127.0.0.1:8778
viola from bf8cf715445d
➜ curl http://127.0.0.1:8778
viola from 15d94216ff07
And every container outputs requests to stdout, which is accessible by standard docker logs:

➜ docker logs bf8cf7
2016/11/04 03:25:35 start serving...
2016/11/04 03:25:51 [GET] at "/" takes 41.015µs
2016/11/04 03:25:53 [GET] at "/" takes 26.656µs

For newest updates, please refer to the corresponding github repo: https://github.com/cizixs/whoami.

Docker Pull Command
Owner
cizixs

Comments (1)
cizixs
a year ago

Please let me know if you have any problem.