Ubuntu - 升级 docker-compose 版本

发布于 2025-01-10 20:14:25 字数 1024 浏览 0 评论 0原文

Docker 新手,所以这可能是基本的,但在我谷歌搜索后我仍然没有找到解决方案

我有一个 docker-compose.yml 文件我正在尝试运行(该文件的版本是“3.4”,但我收到错误:

"The compose file is invalid because:
     networks.default value Additional properties are not allowed ('name' was unexpected)

这是 docker-compose 文件失败的部分:

networks:
    default:
        driver: bridge
        name: nssams_bridge

当我运行时(我在 Ubuntu 20.04 上)

docker-compose --version

它说版本是 1.25.0,我不确定这是否是一个足够高的版本来支持3.4,是我的猜测,

但我尝试了很多方法来更新 docker-compose,但似乎都不起作用:

并且

sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

sudo apt upgrade docker-compose

sudo pip install docker-compose

所有这些之后, docker-compose --version 命令仍然返回 1.25 .0,构建未知

那么如何升级 docker-compose 版本呢?

new to Docker so this may be basic, but after my googling I have still not found a solution

I have a docker-compose.yml file I am trying to run (version for the file is "3.4", but I am getting the error:

"The compose file is invalid because:
     networks.default value Additional properties are not allowed ('name' was unexpected)

This is the portion of the docker-compose file that is failing:

networks:
    default:
        driver: bridge
        name: nssams_bridge

When I run (I am on Ubuntu 20.04)

docker-compose --version

It says the version is 1.25.0, I am not sure if that is a high enough version to support 3.4, is my guess.

But I have tried to update docker-compose many ways and none of them seem to work.

I have tried:

sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

and

sudo apt upgrade docker-compose

as well as

sudo pip install docker-compose

but after all of these, the docker-compose --version command still returns 1.25.0, build unknown

So how do I upgrade the docker-compose version?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

疑心病 2025-01-17 20:14:25

name: 选项 是在 Compose 文件格式 3.5 中添加的,因此您的 3.4 版本太旧了一步。我会使用 3.8 或 3.9,除非您有特定原因使用较旧的版本:

version: '3.8' # networks: { name: } requires a minimum of 3.5
networks:
    default:
        driver: bridge
        name: nssams_bridge

对于许多实际用途,您也可以让 Compose 选择网络名称,因为您很少会直接与它交互。如果您需要手动 docker network 命令或从另一个 Compose 文件引用网络,Compose 会将网络命名为 projectname_default,使用当前目录的名称作为项目名称。如果您可以接受,那么您可以完全删除此 networks: 块。

The name: option was added in Compose file format 3.5, so your 3.4 is one step too old. I'd use 3.8 or 3.9 unless you have a specific reason to use something older:

version: '3.8' # networks: { name: } requires a minimum of 3.5
networks:
    default:
        driver: bridge
        name: nssams_bridge

For many practical uses you can also just let Compose choose the name of the network, since you'll rarely interact with it directly. Should you need manual docker network commands or to refer to the network from another Compose file, Compose will name the network projectname_default, using the current directory's name as the project name. If that's acceptable for you then you can delete this networks: block entirely.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文