我在 Ubuntu 20.04 VM 中使用 docker-compose。我的 docker-compose 版本是 docker-compose version 1.25.0, build unknown
。当我尝试构建时,出现此错误:
ERROR: Version in "./docker-compose.yml" is unsupported. You might be seeing this error because you're using the wrong Compose file version. Either specify a supported version (e.g "2.2" or "3.3") and place your service definitions under the `services` key, or omit the `version` key and place your service definitions at the root of the file to use version 1.
For more on the Compose file format versions, see https://docs.docker.com/compose/compose-file/
如何在 Ubuntu 上升级到最新版本的 docker-compose 来解决此问题?
该文件如下所示:
version: "3.8"
services:
...
networks:
...
最佳答案
如果您不使用“3.8”中的功能,最简单的方法是降级“docker-compose.yml”中的版本号。对于1.25.0版本,看起来不大于“3.7”或“2.4”。
要升级您的 compose 安装,git 存储库上的自述文件有 various options for installing docker-compose 。在 Linux 安装中捆绑 docker compose 命令之前,我的偏好是使用 pip install docker-compose。
关于docker - Ubuntu docker-compose 错误的 Compose 文件版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69269195/