wait_for
is a rust based cli designed to synchronize services such as docker containers. It is highly inspired by eficode/wait-for
, but rewritten to use with rust.
To install the cli first you need to clone repository locally:
git clone https://github.com/aktitarov/wait_for.git && cd wait_for
Then install it to your path using cargo:
cargo install --path .
``` Waits for another service to become available
USAGE:
wait_for [OPTIONS] --host
FLAGS: --help Prints help information -V, --version Prints version information
OPTIONS:
-h, --host
ARGS:
To check if google.com is available:
wait_for -h www.google.com -p 80 -- echo "Google is up"
To wait for database container to become available:
``` version: '3'
service: database: image: postgres:latest app: build: . command: sh -c 'waitfor -h database -p 5432 -- ./target/release/app' dependson: - database ```
Make sure netcat is installed in your Dockerfile before running the command.
RUN apt-get -q update && apt-get -qy install netcat
https://stackoverflow.com/questions/44663180/docker-why-does-wait-for-always-time-out