centOS7下使用docker安装sonatype nexus3服务器

       近期由于工作变化原因,需要重新搭建nexus作为本地镜像仓库,也记不起来前一次安装是什么时间了,重新找了度娘,最后选择docker安装方案。

一、服务器准备

1、双核CPU,4G内存

2、操作系统:centOS7.5

二、安装docker

1、使用root用户进行安装

2、安装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
    yum-config-manager  --add-repo  https://download.docker.com/linux/centos/docker-ce.repo
    yum install docker-ce docker-ce-cli containerd.io
    systemctl enable docker
    systemctl start docker

    系统会自动创建docker用户组

三、创建nexus操作系统用户,为了便于管理将安装目录放在nexus用户下
1、添加用户
     useradd nexus -G docker;
     passwd nexus;
2、su - nexus
     mkdir nexus-data
     chmod 777 nexus-data
四、安装nexus3

1、docker pull sonatype/nexus3:3.23.0

2、docker run -d --name nexus3 --restart=always -m 2048M  --memory-swap -1 -p 8081:8081 -p 8082:8082 -p 8083:8083 -p 8084:8084 -p 8085:8085  -v /home/nexus/nexus-data:/nexus-data  sonatype/nexus3:3.23.0

3、查看启动日志
     docker logs nexus3

4、登录修改管理员密码
    http://IP:8081/
     vi nexus-data/admin.password  查看管理员密码,登录后改密

5、配置支持https
    搭建SSL的Nexus官方提供两种方式
    第一种是反向代理服务器,Nexus Repository Manager使用HTTP对外提供服务,建议用nginx代理
    第二种就是比较正常的,在Nexus Repository Manager上做一些配置,使得Nexus Repository Manager直接对外提供HTTPS服务。

6、配置支持的本地仓库类型

centOS7下使用docker安装sonatype nexus3服务器

创建不同类型本地仓库的角色和用户

centOS7下使用docker安装sonatype nexus3服务器

centOS7下使用docker安装sonatype nexus3服务器

6、创建maven本地仓库,后续章节会介绍客户端怎么连接maven本地仓库

      不需要创建,nexus安装完,已经默认就有了,可以直接使用

centOS7下使用docker安装sonatype nexus3服务器

7、创建docker本地镜像仓库,后续章节会介绍客户端怎么连接docker本地仓库

    点击导航的齿轮按钮进入设置页面,进入 Repository->Repositories 点击 Create repository 选择 docker (hosted)
    docker (hosted) 为本地仓库,docker (proxy) 为代理仓库,docker (group) 为聚合仓库。
    其中 Name 为仓库名,HTTP 的输入框则是填写端口号 8082,写好之后滑到页面底部,点击 Create repository 即创建仓库。
    我这边参考maven仓库进行创建centOS7下使用docker安装sonatype nexus3服务器

centOS7下使用docker安装sonatype nexus3服务器

centOS7下使用docker安装sonatype nexus3服务器

centOS7下使用docker安装sonatype nexus3服务器

centOS7下使用docker安装sonatype nexus3服务器

centOS7下使用docker安装sonatype nexus3服务器

centOS7下使用docker安装sonatype nexus3服务器

centOS7下使用docker安装sonatype nexus3服务器

centOS7下使用docker安装sonatype nexus3服务器

8、创建npm本地仓库,后续章节会介绍客户端怎么连接npm本地仓库

centOS7下使用docker安装sonatype nexus3服务器

centOS7下使用docker安装sonatype nexus3服务器

centOS7下使用docker安装sonatype nexus3服务器

centOS7下使用docker安装sonatype nexus3服务器