https://github.com/drevops/docker-wait-for-dependencies
⏳ Docker container that puts itself on hold until the other services are accessible via TCP
https://github.com/drevops/docker-wait-for-dependencies
Last synced: 5 months ago
JSON representation
⏳ Docker container that puts itself on hold until the other services are accessible via TCP
- Host: GitHub
- URL: https://github.com/drevops/docker-wait-for-dependencies
- Owner: drevops
- License: gpl-3.0
- Created: 2023-10-15T02:36:26.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-08-11T18:54:18.000Z (10 months ago)
- Last Synced: 2025-09-06T09:54:32.687Z (10 months ago)
- Language: Shell
- Homepage:
- Size: 104 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
Docker wait for dependencies
[](https://github.com/DrevOps/docker-wait-for-dependencies/issues)
[](https://github.com/DrevOps/docker-wait-for-dependencies/pulls)
[](https://github.com/drevops/docker-wait-for-dependencies/actions/workflows/test.yml)
[](https://codecov.io/gh/drevops/docker-wait-for-dependencies)



[](https://hub.docker.com/r/drevops/docker-wait-for-dependencies)


---
Container to wait for container healthchecks before proceeding with the stack start
Available for linux/amd64 and linux/arm64 architectures.
## Features
- **TCP connectivity**: Wait for services to be accessible via TCP (using
`host:port` format)
- **Shell command**: Execute arbitrary shell commands and wait for successful
completion
- **Configurable timeouts**: Customizable sleep intervals and timeout periods
- **User-friendly output**: Clear progress indicators and status messages
- **Multi-architecture support**: Available for `linux/amd64` and `linux/arm64`
## Example usage:
### TCP Connectivity
Wait for services to accept TCP connections on specific ports:
```yaml
services:
database:
image: postgres:15-alpine
environment:
POSTGRES_PASSWORD: secret
ports:
- "5432:5432"
cache:
image: redis:7-alpine
ports:
- "6379:6379"
app:
image: alpine:3.22
depends_on:
# Will start only after the wait-for-dependencies finishes waiting
# for both database and cache to be reachable.
wait-for-dependencies:
condition: service_completed_successfully
ports:
- "8000:8000"
wait-for-dependencies:
image: drevops/docker-wait-for-dependencies:25.9.0
depends_on:
- database
- cache
command: database:5432 cache:6379
```
### Combined TCP and Health Check Commands
Wait for both TCP connectivity and custom health check endpoints:
```yaml
services:
api:
image: php:8.3-cli-alpine
ports:
- "8080:8080"
command: php -S 0.0.0.0:8080 -t /app
worker:
image: alpine:3.18
ports:
- "9000:9000"
command: nc -l -p 9000
app:
image: alpine:3.22
depends_on:
# Will start only after the wait-for-dependencies finishes waiting
# for both api and worker to be reachable.
wait-for-dependencies:
condition: service_completed_successfully
ports:
- "8000:8000"
wait-for-dependencies:
image: drevops/docker-wait-for-dependencies:25.9.0
depends_on:
- api
- worker
command:
- api:8080
- worker:9000
- "curl -f http://api:8080/health"
- "test -S /var/run/app.sock"
```
## Configuration
The container supports the following environment variables:
| Variable | Default | Description |
|-------------------|---------|------------------------------------------------------------|
| `SLEEP_LENGTH` | `2` | Time (in seconds) to wait between each check attempt |
| `TIMEOUT_LENGTH` | `300` | Maximum time (in seconds) to wait before giving up |
| `SUMMARY_ENABLED` | `true` | Show summary message when all checks complete successfully |
## Development & Maintenance
```bash
npm run lint # Lint shell scripts and Dockerfile
npm run lint-fix # Auto-fix formatting issues
npm run test-unit # Run unit tests for validation logic
npm run test-functional # Run end-to-end tests with Docker
```
### Versioning
This project uses [CalVer](https://calver.org/) versioning:
- `YY`: Last two digits of the year, e.g., `25` for 2025.
- `m`: Numeric month, e.g., April is `4`.
- `patch`: Patch number for the month, starting at `0`.
Example: `25.4.2` indicates the third patch in April 2025.
### Releasing
Releases are scheduled to occur at a minimum of once per month.
The cross-platform images are built by GitHub actions and pushed to DockerHub:
- `YY.m.patch` tag - when release tag is published on GitHub.
- `latest` - when release tag is published on GitHub.
- `canary` - on every push to `main` branch
### Dependencies update
Renovate bot is used to update dependencies. It creates a PR with the changes
and automatically merges it if CI passes. These changes are then released as
a `canary` version.
---
_This repository was created using the [Scaffold](https://getscaffold.dev/)
project template_
