Skip to content

1. Docker-compose部署

1.1 单独安装

推荐此方式,由于此方式是二进制包,直接下载放到/usr/local/bin/即可

bash
curl -SL https://github.com/docker/compose/releases/download/v2.30.1/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose

#或者自动根据系统下载
curl -L "https://github.com/docker/compose/releases/download/$(curl -s https://api.github.com/repos/docker/compose/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")')" /usr/local/bin/docker-compose

chmod +x /usr/local/bin/docker-compose
curl -SL https://github.com/docker/compose/releases/download/v2.30.1/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose

#或者自动根据系统下载
curl -L "https://github.com/docker/compose/releases/download/$(curl -s https://api.github.com/repos/docker/compose/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")')" /usr/local/bin/docker-compose

chmod +x /usr/local/bin/docker-compose

💡 说明

注意版本兼容性

docker --version

docker-compose --version

1.2 安装插件

官当

docker1.24开始支持插件形式

bash
yum update

yum install docker-compose-plugin

# 安装完成后查看版本号
docker compose version
yum update

yum install docker-compose-plugin

# 安装完成后查看版本号
docker compose version

1.3 卸载

官当

  • 对于插件方式
bash
 yum remove docker-compose-plugin
 yum remove docker-compose-plugin
  • 对于二进制方式
bash
#查看路径
docker info --format '{{range .ClientInfo.Plugins}}{{if eq .Name "compose"}}{{.Path}}{{end}}{{end}}'

rm $DOCKER_CONFIG/cli-plugins/docker-compose
#查看路径
docker info --format '{{range .ClientInfo.Plugins}}{{if eq .Name "compose"}}{{.Path}}{{end}}{{end}}'

rm $DOCKER_CONFIG/cli-plugins/docker-compose