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

Can this work with v3 of docker compose? #3

Closed
ghost opened this issue Sep 12, 2017 · 7 comments
Closed

Can this work with v3 of docker compose? #3

ghost opened this issue Sep 12, 2017 · 7 comments

Comments

@ghost
Copy link

ghost commented Sep 12, 2017

Since docker compose won't support the condition form of depends_on can something like healthcheck works yet?

reference:
https://docs.docker.com/compose/compose-file/#depends_on

@peter-evans
Copy link
Owner

peter-evans commented Sep 13, 2017

No, unfortunately this does not work with v3 of docker compose. From v3 they are not supporting the condition syntax, as you have pointed out. Docker want to move away from docker-compose to the integrated docker stack and Swarm services. When designing how these should work it seems that Docker have made a conscious decision not to support features that wait for containers to be in a "ready" state. They argue that applications depending on other systems should be resilient to failure.

This is a couple of paragraphs taken from the documentation here that explains their reasoning.

The problem of waiting for a database (for example) to be ready is really just a subset of a much larger problem of distributed systems. In production, your database could become unavailable or move hosts at any time. Your application needs to be resilient to these types of failures.

To handle this, your application should attempt to re-establish a connection to the database after a failure. If the application retries the connection, it should eventually be able to connect to the database.

So the options are:

  1. Keep using the v2 format
  2. Use a tool like wait-for-it or dockerize
  3. Make your application resilient to database failure and able to retry it's connection on startup

There is some discussion about this issue here and here.

@satrapu
Copy link

satrapu commented Aug 13, 2020

You could invoke Docker API, as documented here.

@blevine
Copy link

blevine commented Sep 17, 2020

You might want to make a note in your README that this solution doesn't work as of docker-compose V3

@peter-evans
Copy link
Owner

Added a note to the readme about this issue. Thanks.

@srstsavage
Copy link

This is supported in newer versions of docker-compose which support the compose specification. Verified with docker-compose 1.28.4 here.

cc @unparalleled-js

@peter-evans
Copy link
Owner

@shane-axiom Thanks for letting me know! I had no idea about this change.

Docker Compose 1.27.0+ implements the format defined by the Compose Specification. Previous Docker Compose versions have support for several Compose file formats – 2, 2.x, and 3.x. The Compose specification is an unified 2.x and 3.x file format, aggregating properties across these formats.

ref: https://docs.docker.com/compose/compose-file/

It aggregates properties across all the past formats, so you can now use the 2.x condition syntax with the latest version of compose. Perhaps it only works if you don't specify the version at the top of the compose file? I see that the version property is optional now. Anyway, I'll test it out and update this repository.

@peter-evans
Copy link
Owner

Tested and updated the readme. Basically, it doesn't matter what the version property is set to anymore because it's not used. Recent versions of Docker Compose follow the Compose Specification which allows features from previous versions of Compose to be used together.

I think we can consider this issue resolved.

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

4 participants