Ubuntu - 升级 docker-compose 版本
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
name:
选项 是在 Compose 文件格式 3.5 中添加的,因此您的 3.4 版本太旧了一步。我会使用 3.8 或 3.9,除非您有特定原因使用较旧的版本:对于许多实际用途,您也可以让 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: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 networkprojectname_default
, using the current directory's name as the project name. If that's acceptable for you then you can delete thisnetworks:
block entirely.