Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use "start_dependenies" as readiness probes as in Kubernetes #10

Open
ozbillwang opened this issue Aug 22, 2020 · 0 comments
Open

use "start_dependenies" as readiness probes as in Kubernetes #10

ozbillwang opened this issue Aug 22, 2020 · 0 comments

Comments

@ozbillwang
Copy link

ozbillwang commented Aug 22, 2020

Thanks to share the idea on how to set the dependencies between services.

What I want to do with it is, use the service start_dependencies as readness probes as we used in Kubernetes.

So the ideal docker-compose file could be:

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;
      "

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

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

The only change I made is in session of the_web_server, change

    depends_on:
      - the_database
      - another_service

to

    depends_on:
      - start_dependencies

So service the_web_server will only start when start_dependencies reports the other two services are health.

@ozbillwang ozbillwang changed the title Adjust the docker-compose file to use start_dependenies as readiness probes in Kubernetes use "start_dependenies" as readiness probes as in Kubernetes Aug 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant