搭建部署Docker

♀尐吖头ヾ 提交于 2019-12-05 14:43:18

Docker安装准备:

首先看下服务器是否有旧版本,如果有需要卸载并且安装依赖

yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine yum install -y yum-utils  device-mapper-persistent-data  lvm2

然后下载docker仓库repo源:

yum-config-manager --add-repo  https://download.docker.com/linux/centos/docker-ce.repo

安装完成后查看dockers仓库版本信息:

docker-ce --showduplicates | sort -r

docker-ce.x86_64      3:19.03.5-3.el7        docker-ce-stable
docker-ce.x86_64      3:19.03.4-3.el7        docker-ce-stable
docker-ce.x86_64      3:19.03.3-3.el7        docker-ce-stable
docker-ce.x86_64      3:19.03.2-3.el7        docker-ce-stable
docker-ce.x86_64      3:19.03.1-3.el7        docker-ce-stable
docker-ce.x86_64      3:19.03.0-3.el7        docker-ce-stable
docker-ce.x86_64      3:18.09.9-3.el7        docker-ce-stable
docker-ce.x86_64      3:18.09.8-3.el7        docker-ce-stable
docker-ce.x86_64      3:18.09.7-3.el7        docker-ce-stable
docker-ce.x86_64      3:18.09.6-3.el7        docker-ce-stable
docker-ce.x86_64      3:18.09.5-3.el7        docker-ce-stable
docker-ce.x86_64      3:18.09.4-3.el7        docker-ce-stable
docker-ce.x86_64      3:18.09.3-3.el7        docker-ce-stable

  

yum安装docker的时候可以根据仓库版本信息指定版本进行安装,yum -y isntall 包名-版本信息。  docker仓库包名就是docker-ce  版本信息是第二列, 冒号之后,— 之前的内容为版本信息。比如:

yum -y install docker-ce-18.03.5docker -v

在上一步骤可能有的同学会出现安装docker的依赖出现问题,这个报错是是因为container-selinux没有安装或者版本太低的问题,如果本地yum没有此包,那么就要用阿里云的yum源和 epel来更新

执行一下步骤即可解决,然后重新执行安装docker即可

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo 
yum install epel-releaseyum clean allyum makecacheyum install container-selinux

其次还有一种脚本自动部署的安装方式,但是我没有用过,也是参考网上给出的通过 --mirror 选项使用国内源进行安装:

curl -fsSL get.docker.com -o get-docker.sh
sudo sh get-docker.sh --mirror Aliyun
sudo sh get-docker.sh --mirror AzureChinaCloud

 安装完成docker后启动并且测试:

systemctl start docker
docker run hello-word

  

 出现此信息表示docker安装成功!

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!