centos安装Docker CE和Docker Compose
时间: 2023-11-10 20:09:04 浏览: 107
安装Docker CE:
1. 卸载旧版本的Docker
如果您已经安装了旧版本的Docker,请先卸载它们:
```
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
```
2. 安装需要的软件包
```
sudo yum install -y yum-utils \
device-mapper-persistent-data \
lvm2
```
3. 设置Docker CE的稳定版仓库
```
sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
```
4. 安装Docker CE
```
sudo yum install docker-ce docker-ce-cli containerd.io
```
5. 启动Docker
```
sudo systemctl start docker
```
6. 验证是否安装成功
```
sudo docker run hello-world
```
安装Docker Compose:
1. 下载Docker Compose
使用curl命令下载最新的Docker Compose二进制文件:
```
sudo curl -L "https://github.com/docker/compose/releases/download/1.25.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
```
2. 为Docker Compose添加执行权限
```
sudo chmod +x /usr/local/bin/docker-compose
```
3. 验证是否安装成功
```
docker-compose --version
```
阅读全文