Centos7安装docker和docker-compose

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
    
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值