Skip to content
Projets

dadarek/docker-wait-for-dependencies

Voir sur GitHub

À propos

Docker container that blocks until given endpoints are accessible over TCP

Systèmes et infrastructure

Comment ces chiffres sont mesurés

Progression mesurée des étoiles

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
Historique en cours

Variations nettes sur des périodes qui se chevauchent, pas des totaux quotidiens. Les mesures absentes restent vides. Les étoiles indiquent l’intérêt, pas la qualité.

README.md

Original

Example usage:

Sample docker-compose.yml:

version: '2'
services:
  the_database:
    image: ubuntu:14.04
    command: >
      /bin/bash -c "
        sleep 5;
        nc -lk 0.0.0.0 5432;
      "
  another_service:
    image: ubuntu:14.04
    command: >
      /bin/bash -c "
        sleep 8;
        nc -lk 0.0.0.0 5555;
      "

  the_web_server:
    image: ubuntu:14.04
    depends_on:
      - the_database
      - another_service
    command: >
      /bin/bash -c "
        nc -z the_database 5432 &&
        echo Connected to DB and started!
      "

  start_dependencies:
    image: dadarek/wait-for-dependencies
    depends_on:
      - the_database
      - another_service
    command: the_database:5432 another_service:5555

Then, to guarantee that the_database and another_service are ready before running the_web_server:

$ docker-compose run --rm start_dependencies
# Some output from docker compose
$ docker-compose up the_web_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: dadarek/wait-for-dependencies
    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: dadarek/wait-for-dependencies
    environment:
      - SLEEP_LENGTH: 1
      - TIMEOUT_LENGTH: 60

Explorer des projets similaires

Chargement…