Docker: remove obsolete version keys from Compose files

True peace requires the removal of all obsolete keys.

If you use Docker Compose, you may see this message:

$ docker compose up -d
WARN[0000] /.../example/docker-compose.yml: the attribute `version` is obsolete, it will be ignored, please remove it to avoid potential confusion
...

The warning refers to a version key in your Compose file. This key is ignored by Docker Compose since version 2, which was made generally available in 2022. The Docker Compose history documentation states:

Version two of the Docker Compose command-line binary was announced in 2020, is written in Go, and is invoked with docker compose. Compose v2 ignores the version top-level element in the compose.yaml file.

To action the message, remove the version key from your Compose files:

-version: "3.7"
-
 services:
   postgresql:

Your base Compose file is typically called compose.yaml or docker-compose.yml. Remove version from any extra Compose files too, such as override files passed to docker compose -f, which are typically called docker-compose.override.yml or similar.

After removing the version key, docker compose commands should no longer show the warning.

Fin

May your development environment be free of noisy warnings and deprecation notices,

—Adam


😸😸😸 Check out my new book on using GitHub effectively, Boost Your GitHub DX! 😸😸😸


Subscribe via RSS, Twitter, Mastodon, or email:

One summary email a week, no spam, I pinky promise.

Related posts:

Tags: