1.先卸载原有docker版本:
sudo apt-get remove docker docker-engine docker.io containerd runc
2.安装依赖包
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
3.添加 Docker 的官方 GPG 密钥:
curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
4.设置稳定版仓库
sudo add-apt-repository \
"deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/ \
$(lsb_release -cs) \
stable"
5.更新包索引
sudo apt-get update
6.安装docker包
sudo apt-get install docker-ce docker-ce-cli containerd.io
7.先去https://github.com/docker/compose/releases 找到需要安装的版本,并且替换下面的版本
sudo curl -L "https://github.com/docker/compose/releases/download/{版本号}/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
8.添加docker-compose的可执行权限
sudo chmod +x /usr/local/bin/docker-compose
9.添加软链
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
10.执行完成以后就可以使用docker-compose了