美文网首页
05、docker安装

05、docker安装

作者: Kcrise | 来源:发表于2019-04-17 22:26 被阅读0次

环境


VM15 + CentOS 7.6
公司内网(不能直接访问外网,需要通过代理服务器)
主机(192.168.10.13)

安装(使用root)


1.查看官网的文档
https://docs.docker.com/install/linux/docker-ce/centos/


2.卸载旧版本的docker

yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine

表示原来就没有安装docker
image.png

3.安装依赖包

安装所需的软件包
yum install -y yum-utils \
  device-mapper-persistent-data \
  lvm2
获取docker的源
 yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo
image.png

公司使用代理服务器访问外网的,实在是蛋疼。
正常使用yum安装的时候,是可以下载需要的依赖包的。
在/etc/profile 中配置了http_proxy

export http_proxy="http://130.30.3.250:8088"

(对主机配置代理)还是不好使
分析发现这个url是https的,因此猜想配置https的代理应该可以

export http_proxy="http://130.30.3.250:8088"
export https_proxy="http://130.30.3.250:8088"

通过wget 配置代理

vi /etc/wgetrc
增加一行
http_proxy = http://130.30.3.250:8088
https_proxy = http://130.30.3.250:8088
cd /etc/yum.repos.d
wget https://download.docker.com/linux/centos/docker-ce.repo

4.安装

yum install -y docker-ce docker-ce-cli containerd.io
出现了报错信息
image.png

经过近一个小时的分析,才找到解决办法。
先说明一下本人主机的情况下:
由于公司访问外网走的是代理服务器的方式

本人先在本地配置了 本地的yum仓库(192.168.10.13),采用http的方式。

在当前安装docker的主机(192.168.10.12)配置了http和https的代理 (/etc/profile)

export http_proxy="http://130.30.3.250:8088" 
export https_proxy="http://130.30.3.250:8088"

开始的时候yum的repo 有两个docker-ce.repo(刚刚下载的)
docker-ce.repo(之前配置的)内容如下

[http-repos]
name=http-repos 
baseurl=http://192.168.10.13/CentOS7
gpgcheck=0
enabled=1 

当执行yum makecache fast的时候会报错


image.png

原因是访问本地yum仓库的时候 我们配置的是http://192.168.10.13/CentOS7
因此会优先通过代理(export http_proxy="http://130.30.3.250:8088" ) 访问 该仓库,并最终导致报错。

可以使用unset http_proxy使export http_proxy="http://130.30.3.250:8088" 暂时失效。


查看了仓库主机的

[root@localhost Packages]# yum list container-selinux 
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * epel: epel.scopesky.iq
 * http-local: 
已安装的软件包
container-selinux.noarch                                                                2:2.74-1.el7

因此需要下载更高版本的,一通百度之后
http://rpm.pbone.net/index.php3/stat/4/idpl/36266349/dir/scientific_linux_7/com/container-selinux-2.9-4.el7.noarch.rpm.html

下载到本地,然后上传到仓库主机(192.168.10.13)
/var/www/html/CentOS7/Packages(从iso中挂载的)

执行如下命令
createrepo /var/www/html/CentOS7/
生成新的yum依赖关系
回到docker主机(192.168.10.12)
再次执行

yum install -y docker-ce docker-ce-cli containerd.io
本次安装成功

总结

在安装docker的过程中,正常应该不会遇到这么多的问题,以上的问题主要的因素在于 vm所在的宿主机不能直接访问外网。因此 在使用代理服务器接入网络的时候,可能会出现很多乱七八糟的问题。

相关文章

网友评论

      本文标题:05、docker安装

      本文链接:https://www.haomeiwen.com/subject/afdowqtx.html