compose: Validate Compose file and produce better error messages

There are a lot of ways to confuse Compose with a badly-formed docker-compose.yml. This file should be checked when it is read and good error messages should be produced to help users fix the problem.

This could be done by producing a schema for the file, like was done in https://github.com/docker/compose/pull/1348.

These sorts of things should be checked:

  • Top-level object is a dict
  • Each key (a service name) maps to a dict (https://github.com/orchardup/fig/pull/128)
  • String config options (e.g. image) - are numbers allowed? When? Don’t accept YAML’s eager interpretation of values (e.g. true) which should be quoted (#1788)
  • List config options (e.g. volumes) either must be a list, or we helpfully wrap single values in a list for you
  • String-or-list config options (e.g. command, entrypoint)
  • Dictionary config options (e.g. environment)
  • Format of various options (e.g. volumes - see #260)

References: #117 #127

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 25

Commits related to this issue

Most upvoted comments

Have we considered designing a custom syntax that enforces this stuff at a syntactic level? Perhaps something like

web {
  build .
  command python app.py
  link db
  port 8000:8000
}

db {
  image postgres
}