# Docker Wait Hosts
This script is useful when you service depends on postgres, redis or any other services. It prevents get starting errors like "Redis connecting failed".
# Usage
Docker image can have configured following variables:
WAIT_HOSTS- list of host:port separated by coma.WAIT_HOSTS_TIMEOUT- timeout for waiting, after this timeout script exit with code 1.
NOTE: Use only docker's depends_on feature is not enough, because it only starts services before yours,
and don't wait for services to be ready to use.
Example:
application-php:
image: smartsupp/smartsupp-application-php:master
environment:
WAIT_HOSTS: application-mariadb:3306, application-redis:6379
WAIT_HOSTS_TIMEOUT: 300
depends_on:
- application-mariadb
- application-redis
restart: on-failure
# Integration
To properly add support for Docker Wait Host feature you must add into entrypoint following snippet:
if [ -n "$WAIT_HOSTS" ]; then
if [ "$(uname -m)" = 'arm64' ] || [ "$(uname -m)" = 'aarch64' ]; then
/app/docker/wait-arm64
else
/app/docker/wait
fi
fi
And add scripts wait and wait-arm64 with chmod +x.