compose: [BUG] `'version' is obsolete`

Description

After updating to version v2.25.0, the command docker compose pull docker-compose.yaml gives the error 'version' is obsolete

Steps To Reproduce

No response

Compose Version

v2.25.0

Docker Environment

Client: Docker Engine - Community
 Version:    24.0.7
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.12.1
    Path:     /root/.docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.25.0
    Path:     /root/.docker/cli-plugins/docker-compose

Server:
 Containers: 27
  Running: 27
  Paused: 0
  Stopped: 0
 Images: 24
 Server Version: 24.0.7
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 3dd1e886e55dd695541fdcd67420c2888645a495
 runc version: v1.1.10-0-g18a0cb0
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.5.13-1-pve
 Operating System: Debian GNU/Linux 12 (bookworm)
 OSType: linux
 Architecture: x86_64
 CPUs: 4
 Total Memory: 6.723GiB
 Name: hpt630
 ID: beea869f-20a2-4a3f-a514-6ff0f77b5433
 Docker Root Dir: /srv/dev-disk-by-uuid-c1677ca2-07a1-4495-b5c3-ec3f921e2e60/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Anything else?

No response

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 14
  • Comments: 47 (1 by maintainers)

Commits related to this issue

Most upvoted comments

Could the docs be updated?

As I recall, this isn’t a bug, version is only informative since a long time ago now. You can use loose options and you don’t need it, check the spec:

https://github.com/compose-spec/compose-spec/blob/master/spec.md#version-and-name-top-level-elements

It’s called proper SDLC. If this was not done, we would have a bloated, unmaintainable mess. So to your question, everyone benefits from it, maintainers and consumers alike. Cleaner code, accurate documentation and expected functionality. I know I sound like a snob (not trying to be one, honestly), and I understand the frustration with having to make changes, but I would say it is part of it.

But what about when a feature from a newer version is used on older software that doesn’t support it?

The new guys obviously don’t think that far ahead into the future.

We can now no longer look at the first like of docker-compose.yml and understand implicitly how up-to-date it is.

version 3.6 means something. It means “Supports v3 syntax and Docker 18+”.

Removing it removes a lot of important information.

If this was not done, we would have a bloated, unmaintainable mess.

Every change has a cost and a benefit.

My proposal is that if you:

  • kept the version field in the schema
  • included a comment in the code to say it used to be used but isn’t anymore
  • removed mention of version from the docs

Then that would not lead to ongoing bloat or maintainence burden.

Basically instead of doing that, you’ve had to implement a warning and a deprecation period, and many many thousands of people across the world either have to update their code, or live with the warning.

The APIs that people like the most are the ones that retain backwards compatibility, as that is more user friendly.

I appreciate that making breaking API changes is a common pattern that loads of projects do - but that doesn’t necessarily mean they’re always worth it.

There’s writing on this subject out there if you go looking, eg http://blog.ezyang.com/2016/12/thoughts-about-spec-ulation-rich-hickey/

Could the docs be updated?

Sorry to do some action on this obviously closed issue, but i have a Naive question. From a “best practices of programming” point of view, isn’t it always better to be explicit about versioning for the “Just in case” sake?

As I recall, this isn’t a bug, version is only informative since a long time ago now. You can use loose options and you don’t need it, check the spec:

https://github.com/compose-spec/compose-spec/blob/master/spec.md#version-and-name-top-level-elements

Thanks, didn’t know that

A warning is appropriate. Just like a compiler emitting a warning for an unused variable. You don’t have to do anything about the unused variable, just like you don’t have to do anything about the version field. But it doesn’t do anything, and hasn’t done anything for years.

The only thing changing is that now docker compose has actual spec validation built-in. It will tell you if any field is there that isn’t in the spec. This includes typos like cnotext under a build key.

This is a good thing! So either fix your files, using your bulk editor of choice – including submitting a PR, going through CI, etc – or just ignore the warning. It’s doing literally nothing to hurt you. A warning is an informative message, and it doesn’t matter if it’s labeled “warning” or “info” or anything else.

I don’t understand a single word that you said… Huh??

Are you saying that I can’t write docker compose v3 “except for docker”? Well, what else is there???

Does this mean that docker-compose and “other” compose have forked so ahrd that “other compose” can’t understand docker compose v3 files? That seems to be what youre saying.

Please see the documentation link from Xeckt in the first reply. The version top-level element has been deprecated and obsolete in docker compose for some time. The subcommand is now by default using the “default” running mode, where unknown attributes emit a warning, but are ignored. If running in “strict” mode, unknown attributes are an error; and if running in “loose” mode, unknown attributes are ignored and there is no warning. I’m not sure if there are flags implemented yet to run in “strict” or “loose” mode.

The file spec accepted by docker compose is different from the spec accepted by docker stack. The spec for version 2.x is for docker compose, and that subcommand is now removing version as a known attribute; because it is not used. The spec for version 3.x is for docker stack, and includes the additional attributes for choosing deployment targets in a Docker Swarm cluster. The two specifications are not compatible, but share some history.

If you were trying to use the 3.x spec for docker compose, you were using only the parts that overlapped with the 2.x spec. So, in practice, version: 3.6 doesn’t actually mean anything at all, and hasn’t for some time. Because docker compose has never implemented the 3.x spec additions.

Every response I’ve seen so far has been in the vein of “well the maintainers wanted to, so you should live with it”. And yes, I will live with it, and I’ll change my files as I go along - but that doesn’t mean I shouldn’t politely voice my concerns, attempt to clearly state my reasoning, and hope that the maintainers reconsider - or at least avoid making more changes like this in future.

Even with me being on the other side of this preference. I 100% agree with this.

Help me understand somthing here. You are saying the majority of users were not aware or do not care, but all of the sudden the particular warning behavior is deemed critical and the mantainers must pull it back? If they “don’t care” as you say, why should they care about the warning, which is something someone already mentioned here.

They never needed to care before, their docker-compose files did what they told them to without complaint.

docker compose up continued to start the right containers as specified

and then one day, about 3 months ago, after docker compose automatically updated, it started emitting a warning every time they ran it

oh no! a warning, I’d better go look this up and find out what was important enough to merit adding a warning, and then take the appropriate action to make sure my containers keep starting

But then upon finding out what the warning is about (note that the warning itself isn’t self-describing, it doesn’t say what action should be taken), they find out that oh - nope. Nothing will ever break. The specification for docker-compose says that the version field is allowed but must be ignored. But we still have to either live with the warning, or change every compose file in the world.

A widely used configuration file like this is an API. Changing an API has a cost. I have stated repeatedly in this thread why I believe that cost is far larger than the benefit.

Every response I’ve seen so far has been in the vein of “well the maintainers wanted to, so you should live with it”. And yes, I will live with it, and I’ll change my files as I go along - but that doesn’t mean I shouldn’t politely voice my concerns, attempt to clearly state my reasoning, and hope that the maintainers reconsider - or at least avoid making more changes like this in future.

version was declared obsolete as we introduced compose-specification in 2020. It’s been 4 years users would have noticed “compose file format” is not defined by “version 2 vs version 3” antagonism. A warning won’t prevent you to use legacy compose file, will just let you know those are not up-to-date with the state of the art.

Clearly the thought process is that the tool that is deprecating this for a reason

No reason has ever been presented other than “it makes things a bit tidier”.

Last time I checked, that “is” a reason. Might be you do not “agree” with the reason, but it was their prerogative as maintainers. Anyway. As I said, matter of preference and opinion.

As I recall, this isn’t a bug, version is only informative since a long time ago now. You can use loose options and you don’t need it, check the spec:

https://github.com/compose-spec/compose-spec/blob/master/spec.md#version-and-name-top-level-elements

If it’s informative, shouldn’t it NOT output “WARN”? I don’t expect most users interpret WARN as strictly informational.

Love that it is gone. It was so obsolete, last week I was wondering why it is not increasing like everything in life, and now it is gone.

How will docker-compose.yml files for versions 2.x and 3.x be distinguished without the version tag?

I have the same question. How is this going to work…there are definitely differences between 2.x and 3.x that are not compatible with one another?

There’s a lot of files affected, changing across the various repositories requires commits, PRs, CI runs, approvals etc etc etc

Here’s how many public files github search thinks are affected. The number of private files is likely much larger https://github.com/search?q=“version%3A”+language%3Ayaml+path%3Adocker-compose+&type=code

Example code from docker’s own github org still contains the version field: https://github.com/search?q=“version%3A”+language%3Ayaml+path%3Adocker-compose+org%3Adocker&type=code

All of this churn and work and discussion and waste is being created… for what gain?

@bkraul The full question was about hiding without editing many files.

I bet this move is to piss off the podman compose files users and stand out from that XD (it is a joke)

Odd to warn for a version value. I would have left it optional instead of deprecating it. For some people it might have a purpose.

What’s the reasoning behind annoying everyone with the warning and making a few million projects update their files, as oppoosed to just ignoring the field and saying nothing?

I am going to guess ignoring it would not be proper cleanup. This is a deprecation. Deprecations carry warnings before the removal of the feature. It is saying at some point this will generate errors, so clean it up.