Centos7安装docker和docker-compose
一、安装docker
# 使用yum安装docker
yum -y install docker
# 启动
systemctl start docker.service
# 设置为开机自启动
systemctl enable docker.service
二、配置docker加速镜像
1、docker添加阿里云镜像加速器
https://blog.csdn.net/chenjin_chenjin/article/details/86674521
2、配置阿里云加速器
阿里云会根据账号生成一个账号加速器地址,例如:
https://k9e55i4n.mirror.aliyuncs.com
将加速器地址配置到docker的daemon.json文件中:
# 编辑daemon.json
vim /etc/docker/daemon.json
# 设置加速器地址
{
"registry-mirrors": ["https://k9e55i4n.mirror.aliyuncs.com"]
}
最后重新加载和重启docker:
systemctl daemon-reload
systemctl restart docker
三、安装docker-compose
#1.首先检查 Linux 有没有安装 python-pip 包
yum install python-pip
#2.没有 python-pip 包就执行
yum install epel-release -y
#3.执行成功之后,再次执行
yum install python -y
#4.对安装好的 pip 进行升级
pip install --upgrade pip
#5.升级完 pip 工具之后,使用
pip install docker-compose
一般第五步都会报错的
四、解决docker-compose安装报错
-
Error1:cryptography 2.8 has requirement cffi!=1.11.3,>=1.8, but you’ll have cffi 1.6.0 which is incompatible.
# 执行命令 pip install cffi --user -U
-
Error2:Cannot uninstall ‘requests’. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
#执行代码 pip install --ignore-installed requests
-
Error3:
#执行代码 yum -y install python-devel python-subprocess32
-
Error4: Cannot uninstall ‘subprocess32’. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
#执行代码 pip install docker-compose --ignore-installed subprocess32
-
安装完毕后,执行以下代码可查看当前的docker-compose版本
docker-compose version