Compose schema version for depends_on condition to wait for successful service completion

I’m using the new feature where depends_on has condition to wait for successful service completion (introduced in Compose 1.29.0).

However, I still can’t find the feature in the documentation of any of the existing Compose file versions (which is up to version 3.8). So I suppose this means that version: '3.8' is insufficient?

According to this post, 3.9 also exists but is still (now almost a full year after that post!) not documented. Also, the depends_on feature is also added after 3.9 was “specified” so should I really be using version: '3.10'?

You can find the specification here: https://github.com/compose-spec/compose-spec/blob/master/spec.md

There is a likn to it in the Compose File Reference documentation: Overview | Docker Docs

Scroll down until you find this:

The latest Compose file format is defined by the Compose Specification and is implemented by Docker Compose 1.27.0+ .

Click on “Compose Specification”

You can also find a changelog: https://github.com/compose-spec/compose-spec/blob/master/CHANGELOG.md

It says the condition was “(re)introduced”.

I don’t know why this is not in the Compose file v3 reference and there is no reference to exact compose file version numbers.

1 Like

The latest Compose file format is defined by the Compose Specification and is implemented by Docker Compose 1.27.0+ .

I will assume that this means that schema 3.8 is implemented by Compose 1.27.

I did not know about the spec repo and also didn’t notice the link so thanks for the pointer! From Describe short/long syntax and include schema changes · compose-spec/compose-spec@da01f27 · GitHub it indeed looks like the feature belongs to schema version 3.9.

So docker finaly implemented something like the kubernetes init containers for docker-compose?

I am uncertain why they still even support and maintain depends_on, as it’s only an option for “plain” docker-compose deployments, but not for swarm stack deployments.

As soon as you start to use swarm services, you will need to implement “precondtion checks” in your entrypoint script that wait for certain preconditions become true, as `depends_on’ declarations are ignored in swarm stack deployments.

@bisgardo are you getting a specific error message? I stumbled accross a github issue where people wrote it works ootb with the current release - though they didn’t mention a specific schema versions. Just give it a try with docker config and see if docker-compose complains, if it does try to raise the schema version until it does not complain :slight_smile:

@meyay No it worked out of the box (I’m not using swarm) - I was just curious how to do it “right”. :slight_smile:

Yeah having init containers is pretty sweet. It allowed me to get rid of some pretty hideous shell hacks.

I don’t understand what you mean by running docker config?

That’s great news!

Should have been docker-compose config instead of docker config.
I like to use it to let docker-compose verify the compose file and render the output to the screen.

1 Like