搭建部署Docker

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.5
docker -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-release
yum clean all
yum makecache
yum 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安装成功!

 

猜你喜欢

转载自www.cnblogs.com/Dfengshuo/p/11928521.html
今日推荐