Container that waits for other services to be accessible via TCP or a command to return
10K+
Container for wait.sh - https://github.com/adrian-gheorghe/wait
The script waits for a host or multiple hosts to respond on a TCP port but can also wait for a command to output a value. For example you can wait for a file to exist or contain something.
This is mainly useful to link containers that dependend on one another to start. For example you can have a container that runs install scripts that will have to wait for the database to be accessible.
version: '3.3'
services:
db:
image: mysql:5.7
deploy:
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: database
wait:
image: adighe/wait
command: "./wait.sh --wait \"db:3306\" --command \"ls -al\""
./wait.sh --help
wait.sh [[-w | --wait "host:port"] | [[-w | --wait "ls -al /var/www"] | [[-c | --command "printenv"] | [[-t | --timeout 10] | [-h | --help]]
-w "HOST:PORT" | --wait "HOST:PORT" You can specify the HOST and TCP PORT to test
-w "ls -al /var/www" | --wait "ls -al /var/www" Alternatively you can specify a bash command that should return something
-c "printenv" | --command "printenv" Command that should be run when all waits are accessible
-t TIMEOUT | --timeout=TIMEOUT Timeout untill script is killed. Not interval between calls
-i INTERVAL | --interval=INTERVAL Interval between calls
-h | --help Usage / Help
$ ./wait.sh --wait "database_host:3306" --wait "ls -al /var/www/html | grep docker-compose.yml" --command "Database is up and files exist"
$ ./wait.sh --wait "database_host:3306" --wait "database_host2:3306" --command "echo \"Databases are up\""
You can set your own timeout with the -t or --timeout= option. Setting the timeout value to 0 will disable the delay between requests:
$ ./wait.sh --wait "database_host:3306" --wait "database_host2:3306" --command "echo \"Databases are up\"" --timeout 15
Content type
Image
Digest
Size
4.8 MB
Last updated
about 8 years ago
docker pull adighe/wait