docker - Ubuntu docker-compose 错误的 Compose 文件版本

标签 docker ubuntu docker-compose

我在 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/

相关文章:

java - 在 Ubuntu 18.04 上安装 Tomcat 9.0.16

ruby - 在 ubuntu 上为 ruby​​ 2.0 安装 libssl-dev

docker - docker-compose 允许将一个端口映射到两个端口还是我需要一个大使?

php - 带有 php、mysql 和 apache 的 CentOS 上的 Docker 镜像

docker - 在构建时使用 docker-compose 将环境变量传递给 docker 镜像

node.js - Docker - NPM 安装本地包

node.js - 是否可以在 docker 容器中使用 npm serialPort?

azure - 新 Kubernetes 集群自动扩展节点的预拉镜像

docker - 如何在 GCE 和容器镜像上使用持久化存储

java - 从 Eclipse 启动使用 Maven 配置的 JavaFX 应用程序