Skip to content
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

Merge V2 - V3 compose file formats (optional version field) #7588

Merged
merged 7 commits into from
Jul 27, 2020

Conversation

aiordache
Copy link
Contributor

@aiordache aiordache commented Jul 6, 2020

This update introduces an unified compose format that should be compatible with all v2.x and v3.x compose files.
The version field is made optional (the format is automatically detected from the structure of the file).
** version was required to distinguish with 1.x format
For each version, docker-compose validated against its specific schema. Now we have only 2 schemas:

  • v1 schema
  • compose_spec schema (merged v2.x and v3.x)

Related to the conversion from v3 to v2 using the --compatibility flag: the deploy field was being ignored unless this flag was passed and only one container per service was created.

We now apply the properties from deploy regardless of the --compatibility flag.

Test sample:

version: '3.8'
services:
  test:
    image: nginx
    deploy:
      replicas: 3

BEFORE:

One container per service was created unless we pass --compatibility.

$ docker-compose up -d
WARNING: Some services (test) use the 'deploy' key, which will be ignored. Compose does not support 'deploy' configuration - use `docker stack deploy` to deploy to a swarm.
Creating network "hello_default" with the default driver
Creating hello_test_1 ... done

NOW:
Version field is optional, we can either remove it or leave it as it is, result is the same:

services:
  test:
    image: nginx
    deploy:
      replicas: 3
$ docker-compose up -d
WARNING: Some services (test) use the 'deploy' key, which will be ignored. Compose does not support 'deploy' configuration - use `docker stack deploy` to deploy to a swarm.
Creating network "hello_default" with the default driver
Creating hello_test_1 ... done
Creating hello_test_2 ... done
Creating hello_test_3 ... done

Same we get from a v2 file:

services:
  test:
    image: nginx
    scale: 3

v2.x and v3.x schema merging relates to #7201
The removal of compatibility mode relates to https://github.com/docker/dev-tooling-team/issues/121

@aiordache aiordache changed the title Test Merge V2 and V3 schema Test V2 - V3 schema merge Jul 6, 2020
@aiordache aiordache force-pushed the rm_version branch 3 times, most recently from 6c87809 to db101c9 Compare July 8, 2020 10:30
Signed-off-by: aiordache <[email protected]>
@aiordache aiordache changed the title Test V2 - V3 schema merge Merge V2 - V3 compose file formats (optional version field) Jul 8, 2020
@aiordache aiordache marked this pull request as ready for review July 8, 2020 17:55
compose/config/config.py Outdated Show resolved Hide resolved
compose/config/config_schema_v4.0.json Outdated Show resolved Hide resolved
compose/const.py Outdated Show resolved Hide resolved
@jamshid
Copy link

jamshid commented Jul 9, 2020

This is great I was just asking for --compatibility to be the default in #7594, so glad to hear the frustrating version incompatibility is being removed.
Have memswap_limit and mem_swappiness equivalents been added to deploy resources?

aiordache added 2 commits July 10, 2020 11:39
@aiordache
Copy link
Contributor Author

Have memswap_limit and mem_swappiness equivalents been added to deploy resources?

@jamshid we don't have yet equivalent properties in deploy for these. With the unified schema we bring them back as service properties.

I opened an issue on the compose-spec to see if we can have them added/moved to deploy: compose-spec/compose-spec#90

@melicerte
Copy link

I don't clearly understand the consequences of this update.

I have single service extension with extends working with version: "3.5".
This means I can mix up features from 2.x and 3.x like shm_size with no problem ?

@EricHripko
Copy link

Yes @melicerte - you're understanding this correctly 👍 Post-1.27.x, version attribute becomes optional and you can mix 2.x/3.x attributes in the same Compose file 🙂

@melicerte
Copy link

Thanks @EricHripko this is amazing !

@melicerte
Copy link

However shouldn't documentation be updated accordingly ?
For example, concerning extends here https://docs.docker.com/compose/extends/ it could be specified that it works from docker-compose 1.27 and up.

@EricHripko
Copy link

Yep, sounds like a PR to docker.github.io is needed 🙂

kou added a commit to kou/arrow that referenced this pull request Jul 8, 2021
kou added a commit to apache/arrow that referenced this pull request Jul 8, 2021
We need it for "extends".

See also:

  * https://issues.apache.org/jira/browse/ARROW-13199
  * #10611
  * docker/compose#7588

Closes #10681 from kou/require-docker-compose-1.27.0-or-later

Authored-by: Sutou Kouhei <[email protected]>
Signed-off-by: Sutou Kouhei <[email protected]>
bkmgit added a commit to bkmgit/docker.github.io that referenced this pull request Oct 14, 2021
usha-mandya added a commit to docker/docs that referenced this pull request Nov 26, 2021
* Indicate extends can be used again

docker/compose#7588

* Minor style update

Co-authored-by: Usha Mandya <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants