zoukankan      html  css  js  c++  java
  • Maven私服:Docker安装nexus3

    查找nexus3镜像

    docker search nexus

     

    拉取nexus3镜像

    docker pull docker.io/sonatype/nexus3

    查看镜像

    docker images

    运行nexus容器

    docker run -id --privileged=true --name=nexus3.4 --restart=always -p 8081:8081 -v /topcheer/nexus3/nexus-data:/nexus-data 8eb898be2a53(这个是容器id或名称)
    [root@topcheer ~]# docker ps -l
    CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
    b4d0c5712512        8eb898be2a53        "sh -c ${SONATYPE_..."   8 hours ago         Up 3 hours          0.0.0.0:8081->8081/tcp   nexus3
    [root@topcheer ~]#

    解释:
    -id 创建守护式容器
    --privileged=true 授予root权限(挂载多级目录必须为true,否则容器访问宿主机权限不足)
    --name=名字 给你的容器起个名字
    -p 宿主机端口:容器端口映射
    -v 宿主机目录:容器目录 目录挂载

     

    注意:
    运行容器后访问主机+配置的宿主机映射端口无反应时,请稍等几分钟(视配置时间长短不一),等待nexus3完成初始化才能访问成功

    访问nexus3

    登录

    默认admin密码在容器里面

    [root@topcheer nexus-data]# docker exec -it b4d0c5712512 /bin/bash
    bash-4.4$
    bash-4.4$
    bash-4.4$ cd /
    bash-4.4$ ls -l
    total 16
    lrwxrwxrwx.   1 root  root     7 Aug 12  2018 bin -> usr/bin
    dr-xr-xr-x.   2 root  root     6 Aug 12  2018 boot
    drwxr-xr-x.  15 root  root  3100 Nov  6 08:16 dev
    drwxr-xr-x.   1 root  root    66 Nov  6 08:03 etc
    -rwxr-xr-x.   1 root  root  2120 Oct  9 16:17 help.1
    drwxr-xr-x.   2 root  root     6 Aug 12  2018 home
    lrwxrwxrwx.   1 root  root     7 Aug 12  2018 lib -> usr/lib
    lrwxrwxrwx.   1 root  root     9 Aug 12  2018 lib64 -> usr/lib64
    drwxr-xr-x.   2 root  root    21 Oct  9 16:17 licenses
    drwx------.   2 root  root     6 Sep 16 12:24 lost+found
    drwxr-xr-x.   2 root  root     6 Aug 12  2018 media
    drwxr-xr-x.   2 root  root     6 Aug 12  2018 mnt
    drwxr-xr-x.  16 nexus nexus 4096 Nov  6 08:16 nexus-data
    drwxr-xr-x.   1 root  root    22 Oct  9 16:17 opt
    dr-xr-xr-x. 334 root  root     0 Nov  6 08:16 proc
    dr-xr-x---.   1 root  root    23 Sep 16 12:29 root
    drwxr-xr-x.   1 root  root    18 Oct  9 16:16 run
    lrwxrwxrwx.   1 root  root     8 Aug 12  2018 sbin -> usr/sbin
    drwxr-xr-x.   2 root  root     6 Aug 12  2018 srv
    dr-xr-xr-x.  13 root  root     0 Nov  6 08:09 sys
    drwxrwxrwt.   1 root  root    30 Nov  6 08:04 tmp
    -rwxr-xr-x.   1 root  root   341 Oct  9 16:17 uid_entrypoint.sh
    -rwxr-xr-x.   1 root  root   267 Oct  9 16:17 uid_template.sh
    drwxr-xr-x.   1 root  root    81 Sep 16 12:25 usr
    drwxr-xr-x.   1 root  root    24 Nov  6 08:04 var
    bash-4.4$ pwd
    /
    bash-4.4$ cd nexus-data/
    bash-4.4$ ls -l
    total 32
    -rw-r--r--.   1 nexus nexus   36 Nov  6 08:05 admin.password
    drwxr-xr-x.   3 nexus nexus   21 Nov  6 08:05 blobs
    drwxr-xr-x. 296 nexus nexus 8192 Nov  6 08:16 cache
    drwxr-xr-x.   6 nexus nexus  113 Nov  6 08:04 db
    drwxr-xr-x.   3 nexus nexus   36 Nov  6 08:08 elasticsearch
    drwxr-xr-x.   3 nexus nexus   45 Nov  6 08:04 etc
    drwxr-xr-x.   2 nexus nexus    6 Nov  6 08:04 generated-bundles
    drwxr-xr-x.   2 nexus nexus   33 Nov  6 08:04 instances
    drwxr-xr-x.   3 nexus nexus   19 Nov  6 08:04 javaprefs
    drwxr-xr-x.   2 nexus nexus    6 Nov  6 08:04 kar
    -rw-r--r--.   1 nexus nexus    1 Nov  6 08:16 karaf.pid
    drwxr-xr-x.   3 nexus nexus   18 Nov  6 08:04 keystores
    -rw-r--r--.   1 nexus nexus   14 Nov  6 08:16 lock
    drwxr-xr-x.   4 nexus nexus  125 Nov  6 08:17 log
    drwxr-xr-x.   2 nexus nexus    6 Nov  6 08:04 orient
    -rw-r--r--.   1 nexus nexus    5 Nov  6 08:16 port
    drwxr-xr-x.   2 nexus nexus    6 Nov  6 08:04 restore-from-backup
    drwxr-xr-x.   9 nexus nexus 4096 Nov  6 08:16 tmp
    bash-4.4$ cat admin.password
    8e7256d8-b6e4-4ea6-b5ca-2f0979493119bash-4.4$

    登陆以后修改密码为admin1234

    查看仓库

     

    在项目中配置私服

    拷贝public仓库地址

     

    配置到你本地maven的settings文件
    注意:是public group仓库地址而不是releases或snapshots仓库,public默认包含了这两个仓库

    <profile>
            <id>dev</id>
            <repositories>
                <repository>
                    <id>nexus</id>
                    <url>http://nexus.topcheer.xyz:8081/nexus/content/groups/public/</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </repository>
            </repositories>
            <pluginRepositories>
                <pluginRepository>
                    <id>public</id>
                    <name>Public Repositories</name>
                    <url>http://nexus.topcheer.xyz:8081/nexus/content/groups/public/</url>
                </pluginRepository>
            </pluginRepositories>
        </profile>
    
      <activeProfiles>  
          <activeProfile>dev</activeProfile>  
        </activeProfiles>
    
    

    配置maven settings文件的服务器用户名密码
    注意:id为私服中releases和snapshots仓库名,必须一致

    <server>
          <id>docker-hub</id>
          <username>admin</username>
          <password>Harbor12345</password>
        </server>
         <server>  
            <id>maven-releases</id>  
            <username>admin</username>  
            <password>admin123</password>  
          </server>  
          <server>  
            <id>maven-snapshots</id>  
            <username>admin</username>  
            <password>admin123</password>  
          </server> 
     

    在项目父pom文件中配置部署环境,注意id及URL必须与nexus仓库对应

    <distributionManagement>
            <repository>
                <id>maven-releases</id>
                <name>Nexus Release Repository</name>
                <url>http://192.168.180.112:8081/repository/maven-releases/</url>
            </repository>
            <snapshotRepository>
                <id>maven-snapshots</id>
                <name>Nexus Snapshot Repository</name>
                <url>http://192.168.180.112:8081/repository/maven-snapshots/</url>
            </snapshotRepository>
        </distributionManagement>

    重新打开项目,对需要的模块进行deploy

     结果:

  • 相关阅读:
    后台管理系统-使用AdminLTE搭建前端
    后台管理系统-创建项目
    C# 抽象类、抽象属性、抽象方法
    LOJ6519. 魔力环(莫比乌斯反演+生成函数)
    LOJ6502. 「雅礼集训 2018 Day4」Divide(构造+dp)
    LOJ6503. 「雅礼集训 2018 Day4」Magic(容斥原理+NTT)
    一些说明
    从DEM数据提取点数据对应的高程
    arcmap如何打开或关闭启动时的“getting started”界面
    python如何从路径中获取文件名
  • 原文地址:https://www.cnblogs.com/dalianpai/p/11809668.html
Copyright © 2011-2022 走看看