test docker image before pushing
This commit is contained in:
parent
6eafa51fa8
commit
1438243934
3 changed files with 34 additions and 0 deletions
29
test_image.sh
Executable file
29
test_image.sh
Executable file
|
|
@ -0,0 +1,29 @@
|
|||
#!/bin/bash
|
||||
set -exo pipefail
|
||||
|
||||
docker_image=$1
|
||||
port=$2
|
||||
|
||||
wait_start() {
|
||||
for in in {1..10}; do
|
||||
if /usr/bin/curl -s -m 5 -f "http://localhost:${port}/metrics" > /dev/null ; then exit 0 ;
|
||||
else
|
||||
sleep 1
|
||||
fi
|
||||
done
|
||||
|
||||
exit 1
|
||||
|
||||
}
|
||||
|
||||
docker_start() {
|
||||
docker run -d -p "${port}":"${port}" "${docker_image}"
|
||||
}
|
||||
|
||||
if [[ "$#" -ne 2 ]] ; then
|
||||
echo "Usage: $0 quay.io/prometheus/node-exporter:v0.13.0 9100" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
docker_start
|
||||
wait_start
|
||||
Loading…
Add table
Add a link
Reference in a new issue