GithubHelp home page GithubHelp logo

depends-on-condition's Introduction

depends_on: condition

This project contains an example of using the condition form of depends_on in Compose projects. This functionality was recently revived as part of the Compose Spec and requires Docker Compose v1.27.0+.

This project grew out of a talk given at the Docker Community All Hands meeting on 11 March 2021.

Design

There are two services: describer and web. web is defined to have a dependency on describer (using the condition: service_healthy form of depends_on), so Compose waits for describer to start and become healthy before starting web.

The describer service has a simulated startup time of 10 seconds and a health check defined that dependent services can use to wait on. The web service has a simulated hard dependency on the describer service, exiting if the latter isn't available immediately when web starts.

Usage

To run the project, use:

docker-compose up --build

After the describer service starts, you'll see the project wait for about 10 seconds while it waits for the service to become healthy. After that, the web service will start and be available on http://localhost:8080.

Refresh the page repeatedly for inspirational messages (and to ensure that the services are communicating).

To tear down the project, use:

docker-compose down --rmi=local

depends-on-condition's People

Contributors

xenoscopic avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.