microsoft/compose-language-service

Idea: Linting support for docker-compose.yml files

lostintangent opened this issue · 14 comments

It would make it a lot simpler to author Dockerfile and docker-compose.yml files if you could view actionable linting errors from within VS Code. For example, Docker Compose includes JSON schema files for its various formats (e.g. v2.0) that document how to determine whether a compose file is valid or not.

Updating this to mention just docker-compose.yml files, since we recently introduced linting suport for Dockerfiles.

Any chance to see this soon?

@rcjsuen is supporting this feature on your roadmap?

@PrashanthCorp I have considered this in the past but never even got started working on a prototype.

I assumed people would use some sort of YAML editor/validation tool to support this use case...but maybe not everyone wants to install a YAML editor.

A docker-compose.yml file can be valid yaml but not valid for docker-compose. I think linting if keys exist and have proper values set would be very valuable for this extension.

Anyone on this ticket that needs this should be able to get something decent with Red Hat's YAML extension. You can use something like the following in your settings.json file.

{
    "yaml.schemas": {
        "https://raw.githubusercontent.com/docker/cli/master/cli/compose/schema/data/config_schema_v3.8.json": "docker-compose.yml"
    }
}

A complete list of all versions is available here https://github.com/docker/compose/tree/master/compose/config

Thanks for finding that @SuperSandro2000!

This is also available on schemastore:
https://www.schemastore.org/json/

I've investigated this and ultimately the conclusion I've reached is that without just straight-up copying the functionality of the YAML extension, I could not do as good of a job as they've already done. So rather than try to implement this, I'm going to close this issue, since with #122 it is now much more user-friendly to have both the YAML and Docker extensions' language services for compose files working side-by-side.

Orthogonally, the compose spec is short of a lot of features (e.g. descriptions, compose-spec/compose-spec#138) and could use some attention, but that would be necessary even if we added schema validation to this language service.