前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Docker安装Nexus3私服以及使用

Docker安装Nexus3私服以及使用

作者头像
全栈程序员站长
发布2022-09-14 11:28:06
4.2K0
发布2022-09-14 11:28:06
举报
文章被收录于专栏:全栈程序员必看

大家好,又见面了,我是你们的朋友全栈君。

目录

一、Nexus简介

二、安装步骤(使用docker)

三、测试与使用

四、问题及解决


一、Nexus简介

nexus的全称是Nexus Repository Manager,是Sonatype公司的一个产品。它是一个强大的仓库管理器,极大地简化了内部仓库的维护和外部仓库的访问。

主要用它来搭建公司内部的maven私服。但是它的功能不仅仅是创建maven私有仓库这么简单,还可以作为nuget、docker、npm、bower、pypi、rubygems、git lfs、yum、go、apt等的私有仓库

二、安装步骤(使用docker)

1、搜索Nexus3镜像

代码语言:javascript
复制
docker search nexus
Docker安装Nexus3私服以及使用
Docker安装Nexus3私服以及使用

​2、拉取Nexus3镜像

代码语言:javascript
复制
docker pull sonatype/nexus3
Docker安装Nexus3私服以及使用
Docker安装Nexus3私服以及使用

​3、创建Nexus3容器

代码语言:javascript
复制
docker run -itd -p 8081:8081 --privileged=true --name nexus3 \
-v /data/nexus-data:/var/nexus-data --restart=always docker.io/sonatype/nexus3

4、进入Nexus3容器

代码语言:javascript
复制
docker exec -it nexus3 /bin/bash 

三、测试与使用

1、访问

访问http://192.168.51.187:8081/

2、登录

使用docker安装完成后, 登录是提示admin用户的密码在/nexus-data/admin.password 中, 如下图所示, 获取密码后,即可登录, 登录后即可修改密码

Docker安装Nexus3私服以及使用
Docker安装Nexus3私服以及使用
Docker安装Nexus3私服以及使用
Docker安装Nexus3私服以及使用

3、登录成功后,即可查看

Docker安装Nexus3私服以及使用
Docker安装Nexus3私服以及使用

4、创建和修改仓库

Docker安装Nexus3私服以及使用
Docker安装Nexus3私服以及使用

5、Maven中 settings.xml 中配置

代码语言:javascript
复制
<!--添加对应的server与用户名和密码-->
<servers>
    <server>
        <id>cpzx-release</id>
        <username>dev-user</username>
        <password>dev2021</password>
    </server>
	
	<server>
        <id>cpzx-snapshot</id>
        <username>dev-user</username>
        <password>dev2021</password>
    </server>-->
  </servers>

<!--添加对应的server与用户名和密码-->
<mirrors>
	 <mirror>
        <id>cpzx-group</id>
        <mirrorOf>*</mirrorOf>
        <url>http://192.168.51.187:8081/repository/cpzx-group/</url>
    </mirror>
  </mirrors>

<profiles>
   <profile>  
      <id>dev</id>
      <repositories>
        <repository>
          <id>cpzx-group</id>
          <url>http://192.168.51.187:8081/repository/cpzx-group/</url>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
            <updatePolicy>always</updatePolicy>
          </snapshots>
        </repository>
      </repositories>
      <activation>
        <activeByDefault>true</activeByDefault>      
        <jdk>1.8</jdk>
      </activation>
      <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
      </properties>
    </profile>
</profiles>

<!--激活-->
<activeProfiles>
    <activeProfile>dev</activeProfile>
</activeProfiles>

6、java项目中pom.xml中配置

代码语言:javascript
复制
<!--向Nexus私服发布组件的必要配置 -->
<distributionManagement>
    <repository>
        <id>cpzx-release</id>
        <name>Releases</name>
        <url>http://192.168.51.187:8081/repository/cpzx-release/</url>
    </repository>
    <snapshotRepository>
        <id>cpzx-snapshot</id>
        <name>Snapshot</name>
        <url>http://192.168.51.187:8081/repository/cpzx-snapshot/</url>
    </snapshotRepository>
</distributionManagement>

四、问题及解决

1、问题描述, 创建容器时, 内存不足

INFO: os::commit_memory(0x0000000717000000, 1890582528, 0) failed; error=’Cannot allocate memory’ (errno=12)

# There is insufficient memory for the Java Runtime Environment to continue.

# Native memory allocation (mmap) failed to map 1890582528 bytes for committing reserved memory.

# An error report file with more information is saved as:

# /opt/sonatype/nexus/hs_err_pid1.log

解决方法:无法分配内存, 调整内存后, 正常创建

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/158722.html原文链接:https://javaforall.cn

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2022年7月1,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 一、Nexus简介
  • 二、安装步骤(使用docker)
  • 三、测试与使用
  • 四、问题及解决
相关产品与服务
容器镜像服务
容器镜像服务(Tencent Container Registry,TCR)为您提供安全独享、高性能的容器镜像托管分发服务。您可同时在全球多个地域创建独享实例,以实现容器镜像的就近拉取,降低拉取时间,节约带宽成本。TCR 提供细颗粒度的权限管理及访问控制,保障您的数据安全。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档