Centos安装Docker、Docker-compose

  • Centos安装Docker、Docker-compose已关闭评论
  • 13 次浏览
  • A+
所属分类:.NET技术
摘要

要求 CentOs7 系统的内核版本高于 3.10,可通过如下指令查看版本需先安装必要的软件包,yum-utils、device-mapper-persistent-data、lvm2


Docker的搭建

Docker版本要求

要求 CentOs7 系统的内核版本高于 3.10,可通过如下指令查看版本

uname -r 

更新yum

需先安装必要的软件包,yum-utilsdevice-mapper-persistent-datalvm2

yum-utils:提供一个yum-config-manager单元,device-mapper-persistent-datalvm2用于储存设备映射(devicemapper)必须的两个软件包

sudo yum update sudo yum install -y yum-utils device-mapper-persistent-data lvm2 

配置稳定的仓库

配置阿里云仓库,仓库配置会保存到/etc/yum.repos.d/docker-ce.repo文件中

sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo 

更新Yum安装的相关Docker软件包

sudo yum makecache fast#会出错 # centos8使用这个命令,centos8无fast参数 sudo yum makecache 

安装Docker

安装步骤

  1. 查看版本,可指定版本安装
    yum list docker-ce --showduplicates | sort -r
  2. 安装
    yum install -y docker-ce docker-ce-cli

出现错误:problem with installed package buildah-1.22.3-2.module_el8.5.0+911+f19012f9.x86_64

错误信息

Repository extras is listed more than once in the configuration Last metadata expiration check: 0:08:23 ago on Tue 18 Oct 2022 13:44:28 CST. Error:   Problem: problem with installed package buildah-1.22.3-2.module_el8.5.0+911+f19012f9.x86_64   - package buildah-1.22.3-2.module_el8.5.0+911+f19012f9.x86_64 requires runc >= 1.0.0-26, but none of the providers can be installed   - package containerd.io-1.4.3-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64   - package containerd.io-1.4.3-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64   - package docker-ce-3:20.10.18-3.el8.x86_64 requires containerd.io >= 1.4.1, but none of the providers can be installed   - package containerd.io-1.4.3-3.2.el8.x86_64 conflicts with runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64   - package containerd.io-1.4.3-3.2.el8.x86_64 obsoletes runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64   - package containerd.io-1.4.10-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64   - package containerd.io-1.4.10-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64   - package containerd.io-1.4.11-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64   - package containerd.io-1.4.11-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64   - package containerd.io-1.4.12-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64   - package containerd.io-1.4.12-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64   - package containerd.io-1.4.13-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64   - package containerd.io-1.4.13-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64   - package containerd.io-1.4.4-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64   - package containerd.io-1.4.4-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64   - package containerd.io-1.4.6-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64   - package containerd.io-1.4.6-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64   - package containerd.io-1.4.8-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64   - package containerd.io-1.4.8-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64   - package containerd.io-1.4.9-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64   - package containerd.io-1.4.9-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64   - package containerd.io-1.5.10-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64   - package containerd.io-1.5.10-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64   - package containerd.io-1.5.11-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64   - package containerd.io-1.5.11-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64   - package containerd.io-1.6.4-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64   - package containerd.io-1.6.4-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64   - package containerd.io-1.6.6-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64   - package containerd.io-1.6.6-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64   - package containerd.io-1.6.7-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64   - package containerd.io-1.6.7-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64   - package containerd.io-1.6.8-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64   - package containerd.io-1.6.8-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64   - cannot install the best candidate for the job   - package runc-1.0.0-56.rc5.dev.git2abd837.module_el8.3.0+569+1bada2e4.x86_64 is filtered out by modular filtering   - package runc-1.0.0-66.rc10.module_el8.5.0+1004+c00a74f5.x86_64 is filtered out by modular filtering   - package runc-1.0.0-72.rc92.module_el8.5.0+1006+8d0e68a2.x86_64 is filtered out by modular filtering (try to add '--allowerasing' to command line to replace conflicting packages or '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)  

解决办法

  1. 删除podman buildah
yum erase podman buildah 
  1. 查看版本,可指定版本安装
yum list containerd.io --showduplicates | sort -r 
  1. 安装containerd.io
yum install -y containerd.io 
  1. 再安装docker-ce docker-ce-cli
yum install -y docker-ce docker-ce-cli 

启动docker

  1. 设置开机自启动
sudo systemctl start docker sudo systemctl enable docker 
  1. 启动
sudo systemctl start docker 
  1. 验证
docker -v 
**出现以下文字,说明安装成功** 
Docker version 20.10.18, build b40c2f6  

卸载docker

yum list installed | grep docker yum remove 移除需要卸载的组件  yum remove docker    docker-client    docker-client-latest    docker-common    docker-latest    docker-latest-logrotate    docker-logrotate    docker-selinux    docker-engine-selinux    docker-engine  rm -rf /etc/systemd/system/docker.service.d  rm -rf /var/lib/docker  rm -rf /var/run/docker 

安装docker-compose

yum install python-pip python-dev pip install docker-compose  # centos8 使用以下命令安装 yum install epel-release python3-pip python3-devel pip3 install --upgrade pip pip3 install docker-compose  

出现以下文字,说明安装成功

docker-compose -v docker-compose version 1.29.2, build unknown