CentOS环境

CentOS安装Docker+Nexus3私有仓库配置

更新YUM

CentOS安装Docker+Nexus3私有仓库配置

CentOS安装Docker+Nexus3私有仓库配置

安装yum-utils依赖包,为yum-config-manager提供支持

CentOS安装Docker+Nexus3私有仓库配置

查看系统目前的repo文件

CentOS安装Docker+Nexus3私有仓库配置

新增repo

CentOS安装Docker+Nexus3私有仓库配置

CentOS安装Docker+Nexus3私有仓库配置

CentOS安装Docker+Nexus3私有仓库配置

安装Docker(CE为社区版,EE为企业版,这里安装社区版)

CentOS安装Docker+Nexus3私有仓库配置

安装到最后显示如图:

CentOS安装Docker+Nexus3私有仓库配置

启动Docker并查看版本信息

CentOS安装Docker+Nexus3私有仓库配置

由于国内网络原因,拉取官方镜像速度非常慢,因此添加阿里云加速器

注册阿里云后会获得加速器地址

CentOS安装Docker+Nexus3私有仓库配置

Docker添加加速器方式

CentOS安装Docker+Nexus3私有仓库配置

参照以上说明,在/etc/docker/daemon.json文件中加入内容(如果没有该jason文件,则新建)

CentOS安装Docker+Nexus3私有仓库配置

重启Docker并查看加速器是否添加成功

CentOS安装Docker+Nexus3私有仓库配置

查看本地现有镜像及容器情况

CentOS安装Docker+Nexus3私有仓库配置

搭建Nexus3私有仓库的目的是像官方仓库一样提供本地私库功能,既能将本地镜像push至Nexus Resposity,也能从Nexus Resposity中pull下镜像。

Docker的私库可以使用HTTP,也可以使用HTTPS,Nexus3都予以支持,本地的方式采用HTTP,因此需要在Docker启动前设置一下信息。

CentOS安装Docker+Nexus3私有仓库配置

重启Docker并查看相关信息

CentOS安装Docker+Nexus3私有仓库配置

准备工作结束,下面开始下载Nexus镜像,从而创建相关容器

CentOS安装Docker+Nexus3私有仓库配置

等待一段时间后,最终下载完成,查看镜像信息

CentOS安装Docker+Nexus3私有仓库配置

下面依据刚刚下载的Nexus镜像创建相关容器并启动

CentOS安装Docker+Nexus3私有仓库配置

查看容器信息

CentOS安装Docker+Nexus3私有仓库配置

在浏览器中访问http://IP:端口号进入Nexus3管理界面,默认用户名为admin,密码为admin123

CentOS安装Docker+Nexus3私有仓库配置

CentOS安装Docker+Nexus3私有仓库配置

登录以后,点击左上方齿轮

CentOS安装Docker+Nexus3私有仓库配置

CentOS安装Docker+Nexus3私有仓库配置

CentOS安装Docker+Nexus3私有仓库配置

CentOS安装Docker+Nexus3私有仓库配置

CentOS安装Docker+Nexus3私有仓库配置

CentOS安装Docker+Nexus3私有仓库配置

私有仓库创建完毕,至此,准备工作已经结束,下面开始验证。

前面我们已经检查过本地目前没有镜像,所以我们先验证将本地镜像push进Nexus私有仓库中。

首先利用阿里云加速器下载一个示例镜像。

CentOS安装Docker+Nexus3私有仓库配置

CentOS安装Docker+Nexus3私有仓库配置

将待上传镜像tag标记后,箭头所示镜像既为我们本次要push验证的镜像

为了进行操作,需要事先进行docker login操作

CentOS安装Docker+Nexus3私有仓库配置

用户名:admin  密码:admin123

push镜像至私有仓库

CentOS安装Docker+Nexus3私有仓库配置

CentOS安装Docker+Nexus3私有仓库配置

push完毕,进入浏览器Nexus控制台查看push结果

CentOS安装Docker+Nexus3私有仓库配置

CentOS安装Docker+Nexus3私有仓库配置

CentOS安装Docker+Nexus3私有仓库配置

如图,我们可以看到镜像push成功!

下面我们开始验证从私有仓库pull镜像到本地,首先确保本地镜像中不存在该镜像,有的话先进行删除。

CentOS安装Docker+Nexus3私有仓库配置

开始pull镜像

CentOS安装Docker+Nexus3私有仓库配置

可以看到,下载速度非常快。

CentOS安装Docker+Nexus3私有仓库配置

pull结束,在本地查看是否下载成功

CentOS安装Docker+Nexus3私有仓库配置

验证完毕!

验证本文档的前提需要掌握Docker相关技术,文中相关内容参考了https://blog.csdn.net/liumiaocn/article/details/62891201,特此声明!

 

相关文章: