Giter VIP home page Giter VIP logo

Comments (7)

peter-evans avatar peter-evans commented on August 17, 2024 54

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.

from docker-compose-healthcheck.

srstsavage avatar srstsavage commented on August 17, 2024 5

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

from docker-compose-healthcheck.

peter-evans avatar peter-evans commented on August 17, 2024 1

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.

from docker-compose-healthcheck.

satrapu avatar satrapu commented on August 17, 2024

You could invoke Docker API, as documented here.

from docker-compose-healthcheck.

blevine avatar blevine commented on August 17, 2024

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

from docker-compose-healthcheck.

peter-evans avatar peter-evans commented on August 17, 2024

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

from docker-compose-healthcheck.

peter-evans avatar peter-evans commented on August 17, 2024

@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.

from docker-compose-healthcheck.

Related Issues (10)

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.