Docker-composer.yml: services.farmer.depends_on contains an invalid type, it should be an array

Great answer to the initial issue on this post. Credit goes to Discord user Big Jim | counterpoint

This is caused by running an old version of Docker. Updating to the latest version fixes it. I do think instructions on how to do that would be helpful in the guide as this question seems to come up in the support and general chats quite frequently.

For anyone who encounters the depends_on contains an invalid type, it should be an array error when running docker compose it could well be that you’re not on the latest version of Docker Compose.

I managed to fall foul of this by running apt install docker-compose which installs v.1.25.0. This version does not parse version 3 docker-compose.yml files properly and cannot understand the (super useful) depends_on with condition features.

The shortest way to fix this appears to be to uninstall Docker Compose and re-install it from the official guide rather than from apt.
The below worked for me:

  • sudo apt remove --purge docker-compose
  • sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
  • sudo chmod +x /usr/local/bin/docker-compose

If all has worked you should get docker-compose version 1.29.2, build 5becea4c or similar from docker-compose --version and you can go ahead and pull/up. This is the official installation guide which I encourage you to at least skim before trusting some random on the internet Install Docker Compose | Docker Documentation

2 Likes