Sample docker image to test various scenarios with Docker.
Just another "Hello World" docker image to be used in various experiments ...
Note: This Docker image is definitely not designed to be used in a production environment as it could result into serious security issues. But it's nice to be added to your toolbox when playing with Docker/Docker Swarm/Kubernetes, etc.
$ docker pull stefanwalther/docker-test
$ docker run -it -p 3000:3000 stefanwalther/docker-test
version: '3.3`
services:
hello-world:
image: stefanwalther/docker-test
ports:
- 3000:3000
environment:
- PORT=3000
PORT
- Port of the web service, defaults to 3000.
Just returns a "Hello World":
{
"text": "Hello World"
}
Returns a typical health-check, useful to test health-checks in a microservice environment.
{
"ts": "2017-12-07T22:25:34.489Z",
"version": "0.3.1",
"name": "docker-test",
"repository": {
"type": "git",
"url": "git+https://github.com/stefanwalther/docker-test.git"
}
}
Execute any command on the machine and get the result.
Parameters:
def
- The command to execute.
Usage:
# Process ls -la
$ curl http://localhost:3000/cmd/?def=ls%20-la
Examples:
ls -la
- list the directorycurl -o -I -L -s -w "%{http_code}\n" http://localhost:3000/health-check
- Get the Http status code of the health-check
Create a cron job, executing a command.
Parameters:
def
- The command to execute.cron
- The cron definition (see https://crontab-generator.org/)
Usage:
# Process "echo foo" with the following cron def: "* * * * *" (every minute)
$ curl http://localhost:3000/cmd-cron?def=echo%20foo&cron=*%20*%20*%20*%20*
References:
- https://capgemini.github.io/development/multi-stage-builds-in-docker/
- https://codefresh.io/blog/node_docker_multistage/
- Using multi-stage builds to reduce Go images: https://blog.alexellis.io/mutli-stage-docker-builds/
- https://github.com/yamalight/node-docker-pkg-demo
Stefan Walther
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue. The process for contributing is outlined below:
- Create a fork of the project
- Work on whatever bug or feature you wish
- Create a pull request (PR)
I cannot guarantee that I will merge all PRs but I will evaluate them all.
Copyright © 2020, Stefan Walther.
MIT