-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Validate compose file on supported API, not version #7201
Comments
I am not even convinced we need to deprecate v1, just try parsing that schema as well. |
(Speaking as a user so take this as an uninformed opinion.) I am a little concerned of how this might impact error handling. If a yml file is not parseable with any of the versions, it may be difficult to identify what the user was trying to do and give a good error message. This concern comes from seeing users mixing version 1 and version 2/3 syntax in a single file, so it's not clear if you should error that there are invalid parameters to the service named "services" or if you should flag the invalid top level keyword from the v1 service name. I do like the idea of merging the 2.0 - 3.x versions into a single parsing since they are all relatively compatible and I've run into plenty of errors for minor version number mismatches that could have been ignored. A few thoughts for how to improve things going forward:
I'm also hesitant to remove the version completely since future releases may need major syntax redesigns the way v1 to v2 did. For instance, adding a "pod" concept to docker services may require a v4 syntax. |
Those 1.13 versions are a fork of Docker, and have many, many issues anyway (not something we should take into account).
This is actually what the
Wondering if we should just error out. My concern here is a bit that compose v1.x may be parseable as a v2.x file, but has a different behavior for the same options (e.g. no network is created for the project, and all containers are started using the default "bridge" network, use legacy This is also my biggest concern with this approach; same fields/options may have different behavior defined between versions; we cannot heuristically determine which of those to pick. I'm slightly tempted to;
(*) note that this means we cannot have "allow additional properties" (so always have |
At first glance, this makes sense to do. But.. it's also assuming that |
itentifying a v1 file is easy as its top-level structure is distinct from v2/v3. So for those if we want to keep backward compatibility we can keep existing code in place, and still rely on on v2/v3 none of the fields AFAICT have significantly changed their meaning. Some where deperecated and replaced, but none switched to a distinct implementation model. v3 is a major update due to field removal, but is mostly compatible if we re-introduce them about a possible v4, this would introduce much more confusion that we already have, if we want to introduce concepts like |
Identify v1 vs v2/v3 in well formatted files should be easy enough, I'm thinking more of the error scenarios when users try to parse:
Do you error that |
I would expect this one to fail as |
This has been approved by the Compose Spec community meeting. |
Is your feature request related to a problem? Please describe.
docker-compose validates a docker-compose.yml file based on
version
top-level element, and use matching json schema for this purpose.Doing so:
version
accordingly, whenever this field is fully supported and mapping to docker engine implementedversion
, not based on actual needs. User to select a recentversion
will get his docker-compose.yaml file rejected when using an old version of the engine (some distro still only support 1.13), whenever new API might not be actually needed.note:
version
is required to distinguish with 1.x format2.x and 3.x are mostly always adding new fields or just replacing them with alternative equivalent fields. 3.x major version removed some fields that are still implemented by docker-compose and artificially rejected withing the code by version range checks.
Describe the solution you'd like
Better than locking features based on declared
version
field, docker-compose should check API exposed by the engine (docker infoApiVersion
) and warn user if some of the fields set by his docker-compose.yml file can't be implemented with this version of the API.So I propose docker-compose to evolve so that:
version
field is made optional. As long as docker-compose.yaml file is valid according to schema is is considered valid. If it doesn't docker-compose will attempt to parse as a 1.x file for backward compatibility, and warn user for deprecationDescribe alternatives you've considered
Additional context
The text was updated successfully, but these errors were encountered: