• 搜索Nexus
  • 在docker容器中加载Nexus镜像
  • 发布本地项目到Nexus私服
    • 配置连接方式
    • 发布指令
    • 打源码包上传插件

搜索Nexus

  在我们打算使用Nexus时,我们先搜索一下docker景象仓库中现成的Nexus镜像。

docker search nexus
  • 1

其展示的结果如下:

[root@localhost ~]# docker search nexus
INDEX       NAME                                                   DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
docker.io   docker.io/sonatype/nexus                               Sonatype Nexus                                  379                  [OK]
docker.io   docker.io/sonatype/nexus3                              Sonatype Nexus Repository Manager 3             337
docker.io   docker.io/sonatype/docker-nexus3                       Sonatype Nexus 3 [DEPRECATED]                   27                   [OK]
docker.io   docker.io/clearent/nexus                                                                               21
docker.io   docker.io/baselibrary/nexus                            ThoughtWorks Docker Image: nexus                7                    [OK]
docker.io   docker.io/accenture/adop-nexus                         ADOP Nexus                                      5                    [OK]
docker.io   docker.io/bradbeck/nexus-https                         Dockerized version of Nexus Repo Manager 3...   5                    [OK]
docker.io   docker.io/frekele/nexus                                docker run --rm --name nexus -p 8081:8081 ...   4                    [OK]
docker.io   docker.io/shifudao/nexus3                              clone from nexus3 image but based from ope...   3                    [OK]
docker.io   docker.io/sonatype/nexus-iq-server                     Sonatype Nexus IQ Server                        3
docker.io   docker.io/cavemandaveman/nexus                         Sonatype Nexus container                        2                    [OK]
docker.io   docker.io/fabric8/nexus                                                                                2                    [OK]
docker.io   docker.io/madmuffin/nexus3                             Sonatype Nexus3 Milestone7 docker image         2                    [OK]
docker.io   docker.io/mcreations/jenkins-with-nexus-support        Jenkins image with correct SSL config for ...   1                    [OK]
docker.io   docker.io/openshiftdemos/nexus                         Sonatype Nexus with JBoss Enterprise repos...   1                    
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17

  在这里,被大家使用频率越高的版本往往STARS指数越高,排位也就越靠前,这样,我们直接拉取第一个来使用就可以了。

docker pull docker.io/sonatype/nexus
  • 1

  如下:

[root@localhost ~]# docker pull docker.io/sonatype/nexus
Using default tag: latest
Trying to pull repository docker.io/sonatype/nexus ...
latest: Pulling from docker.io/sonatype/nexus
af4b0a2388c6: Pull complete
e2c659f5d884: Pull complete
37f6e458506e: Pull complete
b8ce98aa6771: Pull complete
90969e21cd0f: Pull complete
Digest: sha256:90f8ec0dadf5fef6bab1269a96f4e71583dadb366dde3cc664c599da5e1421e7
[root@localhost ~]# docker run -d -p 8081:8081 --name nexus docker.io/sonatype/nexus
5f23e18df895901f33a7abf01870984a65257f977e27266d6d319706b6e06719
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

在docker容器中加载Nexus镜像

  指令如下:

docker run -d -p 8081:8081 --name nexus docker.io/sonatype/nexus
  • 1

  运行结果:

[root@localhost ~]# docker run -d -p 8081:8081 --name nexus docker.io/sonatype/nexus
5f23e18df895901f33a7abf01870984a65257f977e27266d6d319706b6e06719
  • 1
  • 2

  在Nexus运行时,这可能需要等待一段很短的时间,我们可以通过查看Nexus的日志来了解Nexus的运行情况,其指令如下:

docker logs -f nexus
  • 1

  当docker运行起来后,我们就可以在浏览器中进行访问了,访问地址为:

http://192.168.44.128:8081/nexus/#welcome
  • 1

  其中192.168.44.128为虚拟机所对应的ip地址,大家在这里填写自己所在的ip地址即可。

  运行的界面如下:

  当看到这里时,这说明我们的Nexus已经正常运行,可以进行使用了。

  如果想查看与Nexus相关的更多docker镜像信息,可以到这里去查看Nexus的docker镜像官方文档。

https://hub.docker.com/r/sonatype/nexus/
  • 1

  在这里,docker的默认账号为admin,默认密码为admin123,直接将其拿来就可以使用了。

发布本地项目到Nexus私服

配置连接方式

  配置Maven的settings.xml

    <server>
      <id>user-release</id>
      <username>admin</username>
      <password>admin123</password>
    </server>
    <server>
      <id>user-snapshots</id>
      <username>admin</username>
      <password>admin123</password>
    </server>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

  配置项目的pom.xml

<distributionManagement>
    <repository>
      <id>user-release</id>
      <name>user release resp</name>
      <url>http://192.168.44.128:8081/nexus/content/repositories/releases/</url>
    </repository>
    <snapshotRepository>
      <id>user-snapshots</id>
      <name>user snapshots resp</name>
      <url>http://192.168.44.128:8081/nexus/content/repositories/snapshots/</url>
    </snapshotRepository>
  </distributionManagement>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

  该连接地址在Nexus的页面中就可以找到,如:

  直接来拿复制粘贴就可以了。

发布指令

  在项目中,运行下列指令将项目发布到私服中

mvn deploy
  • 1

  或点击IDEA中的deploy快捷指令

  运行结果:

Downloading from user-snapshots: http:www.255055.cn/ //192.168.44.128:8081/nexus/content/repositories/snapshots/com/mycompany/linear-table/2.0-SNAPSHOT/maven-metadata.xml
Uploading to user-snapshots: http://192.168.44.128:8081/nexus/content/repositories/snapshots/com/mycompany/linear-table/2.0-SNAPSHOT/linear-table-2.0-20180409.124308-1.jar
Uploaded to user-snapshots: http://www.douniu178.com 192.168.44.128:8081/nexus/content/repositories/snapshots/com/mycompany/linear-table/2.0-SNAPSHOT/linear-table-2.0-20180409.124308-1.jar (17 kB at 114 kB/s)
Uploading to user-snapshots: http://192.168.44.128:8081/nexus/content/repositories/snapshots/com/mycompany/linear-table/2.0-SNAPSHOT/linear-table-2.0-20180409.124308-1.pom
Uploaded to user-snapshots: http://www.chuangyed.com 192.168.44.128:8081/nexus/content/repositories/snapshots/com/mycompany/linear-table/2.0-SNAPSHOT/linear-table-2.0-20180409.124308-1.pom (1.8 kB at 30 kB/s)
Downloading from user-snapshots: http://192.168.44.128:8081/nexus/content/repositories/snapshots/com/mycompany/linear-table/maven-metadata.xml
Uploading to user-snapshots: http://192.168.44.128:8081/nexus/content/repositories/snapshots/com/mycompany/linear-table/2.0-SNAPSHOT/maven-metadata.xml
Uploaded to user-snapshots: http://192.168.44.128:8081/nexus/content/repositories/snapshots/com/mycompany/linear-table/2.0-SNAPSHOT/maven-metadata.xml (769 B at 20 kB/s)
Uploading to user-snapshots: http://192.168.44.128:8081/nexus/content/repositories/snapshots/com/mycompany/linear-table/maven-metadata.xml
Uploaded to user-snapshots: http://192.168.44.128:8081/nexus/content/repositories/snapshots/com/mycompany/linear-table/maven-metadata.xml (283 B at 7.6 kB/s)

  发布后的结果:

打源码包上传插件

  源码包上传插件如下,将其添加到项目的pom.xml文件中即可。

<build>
    <plugins>
      <plugin> <!-- 打jar包 -->
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>3.0.1</version>
        <configuration>
          <excludes>
            <exclude>**/*.properties</exclude>
          </excludes>
        </configuration>
      </plugin>
      <plugin> <!-- 打源码 -->
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <version>3.0.1<www.boshenyl.cn /version>
        <configuration>
          <attach>true</attach>
        </configuration>
        <executions>
          <execution>
            <phase>compile</phase>
            <goals>
              <goal>jar<www.mcyllpt.com/goal>
            <www.feihuanyule.com /goals>
          </execution>
        </executions>
      </plugin>
    <www.gouyiflb.cn /plugins>
  <www.caibaoyule.cn /build>

  当添加上上述插件后,当我们执行mvn deploy时,我们的项目源码包也将会一并发布到Nexus私服中

用Docker搭建Nexus私服的更多相关文章

  1. Docker 搭建nexus私服

    一.概述 有三种专门的Maven仓库管理软件可以用来帮助大家建立私服:Apache基金会的Archiva.JFrog的Artifactory和Sonatype的Nexus.而Nexus是当前最流行的M ...

  2. Linux Centos7 基于Docker 搭建 Nexus私服搭建

    创建Blob Stores[本地文件存储目录,统一管理] 1.设置名称和工作路径: ps[注意事项]: 1.storage name:自定义名称 2.storage path:存储路径,默认[/nex ...

  3. Linux_Centos中搭建nexus私服

    1.在Linux下搭建Nexus私服 1).下载并且解压      下载  nexus-2.11.2-03-bundle.zip      unzip nexus-2.11.2-03-bundle.z ...

  4. Linux 安装配置maven3.0 以及搭建nexus私服

    http://carvin.iteye.com/blog/785365 一.软件准备 1.apache-maven-3.0-bin.tar.gz 下载地址:http://www.apache.org/ ...

  5. 搭建nexus私服(maven)

    这里提供nexus的直接下载页面的链接: https://www.sonatype.com/download-oss-sonatype maven获取依赖jar包是从中央仓库获取,但很莫名的出现jar ...

  6. Linux安装配置maven以及搭建nexus私服(编写启动脚本)

    2011年07月12日16:32  下面介绍在Linux操作系统下安装配置maven和搭建nexus私服. 一.安装前的准备 下载 jdk http://www.oracle.com/technetw ...

  7. 搭建nexus私服,无法下载相关jar包,报错Repository proxy-mode is BLOCKED_AUTO

    在搭建nexus私服的时候,之前没直接用来下载maven的相关插件jar包,一直可以使用, 结果今天要编译hadoop的时候,在linux上新用maven就报错了,无法下载maven的相关插件(如下) ...

  8. 【原创】Docker 搭建Maven私服nexus 3.17初始密码登录不上问题/admin登陆不上问题

    [原创-转载请说明出处] 博主最近在虚拟机中搭建Maven私服,遇到了一个关键问题就是nexus 3.17版本后初始密码不是admin/admin123. 对于nexus不熟悉的我弄了很长时间!!!心 ...

  9. 基于Docker搭建Maven私服Nexus,Nexus详解

    备注:首先在linux环境安装Java环境和Docker,私服需要的服务器性能和硬盘存储要高一点,内存不足可能到时启动失败,这里以4核8GLinux服务器做演示 一:基于Docker安装nexus3 ...

随机推荐

  1. VIN码识别:毫秒间99%精准识别

    科技改变生活.几年前,人工智能还仅是一个噱头,现在已逐渐融入我们的工作和生活,代替了一些重复性的.繁杂的人工劳动,在提高工作效率的同时,提升了客户体验. 车架号也叫VIN码,由17位数字和字母混合组成 ...

  2. katalon系列三:Project Setting-项目设置

    安装完katalon后,用QQ邮箱注册并登陆,然后新建一个项目.点击菜单Project-Project Setting打开项目设置,接下来介绍几个你可能会用到的设置. 1.Text Design-We ...

  3. 后台可以用layui快速开发

    后台可以用layui快速开发

  4. python函数参数默认值及重要警告

    最有用的形式是对一个或多个参数指定一个默认值.这样创建的函数,可以用比定义时允许的更少的参数调用,比如: def ask_ok(prompt, retries=4, reminder='Please ...

  5. python计算工资个税

    # -*- coding: utf-8 -*- total = int(input("税前总计:")) #公积金10% Gongjijin = total * 0.1 print( ...

  6. react和vue的区别

    1.数据改变的方式 react是通过setState来改变数据,然后重走组件的渲染过程.而vue是通过Object.defineProperty和watcher来显示响应式的数据,所以数据的改变是直接 ...

  7. IMX6移植htop

    top命令查看CPU利用率并不是很方便,因此打算移植htop到imx6上,主要包括以下几个步骤: - 资源下载 htop 下载http://hisham.hm/htop/releases/1.0.1/ ...

  8. 面试中要注意的 3 个 JavaScript 问题

    JavaScript 是 所有现代浏览器 的官方语言.因此,各种语言的开发者面试中都会遇到 JavaScript 问题. 本文不讲最新的 JavaScript 库,通用开发实践,或任何新的 ES6 函 ...

  9. ViewPager的简单使用说明

    前提:工程中使用ViewPager,需要导入google提供的jar包(android-support-v4.jar). 要学习ViewPager的使用,建议直接看官方文档 Creating Swip ...

  10. TensorFlow源码框架 杂记

    一.为什么我们需要使用线程池技术(ThreadPool) 线程:采用“即时创建,即时销毁”策略,即接受请求后,创建一个新的线程,执行任务,完毕后,线程退出: 线程池:应用软件启动后,立即创建一定数量的 ...