Controlling startup order of services -- docker compose parsing error


#1

Hi, I am trying to introduce starting conditions for containers, so that they wait for each other before starting. I am currently doing this with healthchecks.

Here is how my docker-compose.yml looks like:

version: ‘2.1’

init:
build: ./init
healthcheck:
test: ./all_ready.sh
interval: 20s
timeout: 10s
retries: 10

network:
build: ./network
depends_on:
init:
condition: service_healthy

When pushing this to resin remote, I get

[Error] Could not parse compose file
[Error] Service dependencies must be an array
[Error] Not deploying release.

I tried adding “-” in front of the depending service, but this lead to another parsing error.

I tried this docker compose syntax for a docker container outside resin and it worked. Any idea how to fix this in resin?


#4

Hi @ionita ,

This does look like a syntax error, but I cannot tell with much confidence with the existing formatting.

Could you please upload the docker-compose.yml instead? That way the indentation will be kept and it’ll be easier for us to spot any errors there.

Thanks!


#5

Hi @lekkas,

thanks for the reply! Here is the file (renamed from yml to log, as it was otherwise not possible to upload it):

docker-compose.log (387 Bytes)


#6

I think that behaviour is not yet supported by us. Looking at the cocker compose file reference:

depends_on was added in version 2 of docker compose, that we support, and the condition added in 2.1.

As our docs mention, only the version 2’s array format is supported, and that is without the condition, just as

...
  network:
    build: ./network
    depends_on:
      - init
...

We’ll open an internal issue for this. In the meantime, the Docker documentation has some hints how to use a bit of extra tooling to replicate that behaviour, if I read it well.

Let us know if you tried it out, and whether it works…


#8

Hi @imrehg, thanks for you answer! I did indeed used some wrapper scripts to delay the start of containers, after the example of wait-for-*

command: wait-for-container1.sh start-container2

With the healthcheck option I would still have a script executing, maybe it is also a bit more transparent. So looking forward to seeing it supported in the future.