Skip to content

andreiavrammsd/wait-for-it

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Wait for it

Run a command only when port on host is available

Tested on Alpine and Ubuntu

I needed to run a command in an Alpine Docker container only after another process (from other container) was open.

Based on https://github.com/vishnubob/wait-for-it. Many thanks!

Uses: https://en.wikipedia.org/wiki/Netcat

Setup

  • chmod +x wait-for-it.sh
  • Change shebang line as needed:
    • Alpine: #!/usr/bin/env sh
    • Ubuntu: #!/usr/bin/env bash

Usage

./wait-for-it.sh -h host -p port [-c command] [-t timeout] [-q quiet]
    -h          Host or IP under test
    -p          TCP port under test
    -c          Command to execute if test succeeds
    -t          Timeout in seconds, zero for no timeout
    -q          Don't output any status messages

Examples

./wait-for-it.sh -h www.google.com -p 80 -t 5 -c "echo Google is up" -q
./wait-for-it.sh -h www.google.com -p 8080 -t 5

Other

See this, too: https://github.com/jwilder/dockerize

About

Run a command only when port on host is available

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages