A simple container that puts itself on hold until the other services declared in the docker-compose.yml
are accessible via TCP.
Available for linux/amd64
and linux/arm64
architectures.
Sample docker-compose.yml
:
version: '2'
services:
mongo:
image: mongo:6
container_name: mongo
ports:
- 27017:27017
networks:
- my-network
redis:
container_name: redis
image: redis:6
ports:
- 6379:6379
networks:
- my-network
server:
container_name: server
image: server
ports:
- 3000:3000
networks:
- my-network
start_dependencies:
image: drevops/docker-wait-for-dependencies:23.12.0
depends_on:
- mongo
- redis
container_name: wait-for-dependencies
command: mongo:27017 redis:6379
networks:
- my-network
Then, to guarantee that mongo
and redis
are ready before running server
:
$ docker-compose run --rm start_dependencies
# Some output from docker compose
$ docker-compose up server
By default, there will be a 2 second sleep time between each check. You can modify this by setting the SLEEP_LENGTH
environment variable:
start_dependencies:
image: drevops/docker-wait-for-dependencies:23.12.0
environment:
- SLEEP_LENGTH: 0.5
By default, there will be a 300 seconds timeout before cancelling the wait_for. You can modify this by setting the TIMEOUT_LENGTH
environment variable:
start_dependencies:
image: drevops/docker-wait-for-dependencies:23.12.0
environment:
- SLEEP_LENGTH: 1
- TIMEOUT_LENGTH: 60
The main functionality is based on the docker-wait-for-dependencies project. A special thank you to the contributors for their original work.
This repository was created using the Scaffold project template