如何将 docker-compose 升级到最新版本 [英] How to upgrade docker-compose to latest version
问题描述
我已经使用命令安装了 docker-compose
I have installed docker-compose using the command
sudo apt install docker-compose
它安装了 docker-compose 1.8.0 版本并构建了未知
It installed docker-compose version 1.8.0 and build unknown
我需要最新版本的 docker-compose 或至少 1.9.0 的版本
I need the latest version of docker-compose or at least a version of 1.9.0
谁能告诉我应该采取什么方法来升级或卸载并重新安装最新版本.
Can anyone please let me know what approach I should take to upgrade it or uninstall and re-install the latest version.
我已经检查了 docker 网站,可以看到他们建议使用此安装最新版本'
I have checked the docker website and can see that they are recommending this to install the latest version'
sudo curl -L https://github.com/docker/compose/releases/download/1.21.0/docker-compose-$(uname -s)-$(uname -m) -o/usr/local/bin/docker-compose
但在此之前,我必须卸载当前版本,可以使用命令
But before that, I have to uninstall the present version, which can be done using the command
sudo rm/usr/local/bin/docker-compose
但这只能在使用 curl 完成安装时使用.我不确定安装是否像我使用的那样通过 curl 完成
but this can be used only when the installation was done using curl. I am not sure if the installation was done by curl as I have used
sudo apt install docker-compose
请让我知道我现在应该怎么做才能卸载并重新安装 docker-compose.
Please let me know what should I do now to uninstall and re-install the docker-compose.
推荐答案
首先,删除旧版本:
如果通过 apt-get
sudo apt-get remove docker-compose
如果通过 curl
sudo rm /usr/local/bin/docker-compose
如果通过 pip
pip uninstall docker-compose
然后在GitHub的发布页面上找到最新版本或者通过卷曲 API 并使用 grep
或 jq
从响应中提取版本(感谢 dragon788、frbl 和 Sabre Hayati 用于这些改进):
Then find the newest version on the release page at GitHub or by curling the API and extracting the version from the response using grep
or jq
(thanks to dragon788, frbl, and Saber Hayati for these improvements):
# curl + grep
VERSION=$(curl --silent https://api.github.com/repos/docker/compose/releases/latest | grep -Po '"tag_name": "K.*d')
# curl + jq
VERSION=$(curl --silent https://api.github.com/repos/docker/compose/releases/latest | jq .name -r)
最后,下载到您最喜欢的 $PATH 可访问位置并设置权限:
Finally, download to your favorite $PATH-accessible location and set permissions:
DESTINATION=/usr/local/bin/docker-compose
sudo curl -L https://github.com/docker/compose/releases/download/${VERSION}/docker-compose-$(uname -s)-$(uname -m) -o $DESTINATION
sudo chmod 755 $DESTINATION
这篇关于如何将 docker-compose 升级到最新版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!