From 6d04eaf0b0a7d03ed9fc3ad369831703e2bc7a73 Mon Sep 17 00:00:00 2001 From: will Farrell Date: Sun, 22 Jan 2017 12:32:01 -0700 Subject: [PATCH] add default & remove bash --- Dockerfile | 3 +-- README.md | 9 +++------ ping | 6 +++--- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index 65562ca..1adbc4f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,3 @@ FROM alpine:3.5 -RUN apk add --no-cache bash COPY ping / -CMD ["/ping"] \ No newline at end of file +CMD ["sh", "ping"] \ No newline at end of file diff --git a/README.md b/README.md index e87343a..690c6b3 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,15 @@ # docker-ping ## ENV -- `HOSTNAME` Server you would like to continuously ping -- `TIMEOUT` Number of seconds between timeouts +- `HOSTNAME` Server you would like to continuously ping [ default=localhost ] +- `TIMEOUT` Number of seconds between timeouts [ default=300 ] ## docker-compose.yml ```yml -version: "2" - +... services: - ping: image: willfarrell/ping - restart: always environment: HOSTNAME: "10.0.0.61" TIMEOUT: 300 diff --git a/ping b/ping index 73fe54a..6c640ea 100755 --- a/ping +++ b/ping @@ -1,4 +1,4 @@ -#!/bin/bash -echo ping $HOSTNAME every $TIMEOUT sec +#!/bin/sh +echo ping ${HOSTNAME:=localhost} every ${TIMEOUT:=300} sec -while true; do ping -c 1 $HOSTNAME; sleep $TIMEOUT; done; \ No newline at end of file +while true; do ping -c 1 ${HOSTNAME}; sleep ${TIMEOUT}; done; \ No newline at end of file