Skip to content

Instantly share code, notes, and snippets.

@lhess
Last active July 11, 2016 13:52
Show Gist options
  • Save lhess/3fb4d4ebb441bafcbc3c9b3f292ead65 to your computer and use it in GitHub Desktop.
Save lhess/3fb4d4ebb441bafcbc3c9b3f292ead65 to your computer and use it in GitHub Desktop.
check availability of specific port in docker-entrypoint by using netcat (example for elasticsearch)
#!/usr/bin/env bash
echo "Stalling for Elasticsearch..."
for i in {30..0}; do
nc -q 1 elasticsearch 9200 2>/dev/null && break
echo "Elasticsearch init process in progress..."
sleep 1
done
if [ "$i" = 0 ]; then
echo >&2 "Seems like Elasticsearch is not up and running! aborting..."
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment