Docker: remove obsolete version keys from Compose files

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 withdocker compose. Compose v2 ignores theversiontop-level element in thecompose.yamlfile.
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.
😸😸😸 Check out my new book on using GitHub effectively, Boost Your GitHub DX! 😸😸😸
One summary email a week, no spam, I pinky promise.
Related posts:
Tags: docker