019.nexus搭建docker镜像仓库/maven仓库

本文详细介绍了如何在CentOS上安装Docker CE并启动Nexus3,搭建Docker与Maven镜像仓库的过程。涵盖了Docker配置、Nexus3启动参数、解决启动失败问题、创建不同类型Docker仓库及用户角色、通过Docker CLI使用镜像仓库、Nexus搭建Maven仓库的步骤,包括配置maven settings.xml和pom.xml,实现jar包的本地仓库安装与上传。
一、安装docker CE

  参考docker doc

  https://docs.docker.com/install/linux/docker-ce/centos/

 

二、docker启动nexus3
# 1.登录docker hub
docker login

# 2.拉取nexus3镜像
docker pull sonatype/nexus3

# 3.查看镜像
docker images

# 4.启动nexus3
docker run -id --name=nexus3 \
--privileged=true \
--restart=always \
-p 8081:8081 \
-p 10000:10000 \
-p 10010:10010 \
-p 10020:10020 \ 
-v /opt/nexus3/nexus-data:/var/nexus-data \
836c51250912

# 将容器的10000 10010 10020端口映射到host机, 这些端口作为后续nexus3创建的docker镜像仓库支持docker访问的端口


# 5.查看nexus3日志
docker logs -f nexus3

 

三、启动nexus失败的问题

   如果服务器内存太小导致nexus无法启动,可以启用swap

   https://www.cnblogs.com/wuxie1989/p/5888595.html

   https://www.cnblogs.com/kerrycode/p/5246383.html

   https://www.cnblogs.com/bingyeh/p/5913486.html

 

  

Part one: nexus搭建docker镜像仓库

一、nexus3创建docker镜像仓库及用户、角色
  • 使用默认管理账号密码登录nexus3管理界面

  https://www.jianshu.com/p/77af52a75ad8 

  https://segmentfault.com/a/1190000015629878

 

  登录地址: http://服务器ip:8081

 

  • 三种类型的docker镜像仓库

  hosted、proxy、group

  

  设置可以被docker-cli直接访问的端口(启动nexus容器的时候需要将这些端口暴露到host机); 

  

 

 

  • 设置角色、创建用户

   创建角色、设置角色的权限;

  

 

  角色可以继承

  

 

  

 

  创建用户,为用户分配角色;

  

 

 

二、通过docker-cli使用镜像仓库
  • 设置docker-daemon的 insecure-registries

 

# 1.查看docker-daemon配置文件
systemctl status docker.service

# 2.修改配置文件
vi /usr/lib/systemd/system/docker.service

# ExecStart=/usr/bin/dockerd --insecure-registry 47.116.91.161:10000 --insecure-registry 47.116.91.161:10010 --insecure-registry 47.116.91.161:10020   -H fd:// --containerd=/run/containerd/containerd.sock


# 3.重启docker-daemon systemctl daemon-reload # 4.重启docker systemctl restart docker

 

  •  登录到nexus3搭建的docker镜像仓库

  docker login xxx:xxx:xxx:xxx:10010

 

 

 

Part Two: nexus搭建maven仓库

https://www.cnblogs.com/dreamroute/p/5440419.html

https://blog.youkuaiyun.com/ZZY1078689276/article/details/78953011

一、配置mavensettings.xml

安装完成的nexus已经创建了4个maven仓库

 
 
## 私服的id需要与nexus仓库id保持一致
   <server>
        <id>maven-releases</id>
        <username>admin</username>
        <password>admin123</password>
    </server>

 

 

二、修改项目pom.xml
## repository的id与ssettings.xml server id 一致
    <distributionManagement>
        <repository>
            <id>maven-releases</id>
            <name>Nexus-Release-Repository</name>
            <url>http://xx.xxx.xx.xxx:8081/repository/maven-releases/</url>
        </repository>
    </distributionManagement>

 

三、maven build... > goals: deploy

 jar包即可安装到本地仓库即上传到私服

 

四、SNAPSHOT版本
  • release正式仓库则是用来保存稳定的发行版本。

    编译打包时如果发现本地已经存在该版本的模块,则不会再去私服下载。

  • snapshot快照仓库用于保存开发过程中的不稳定版本,

    定义一个组件/模块为快照版本,只需要在pom文件中在该模块的版本号后加上-SNAPSHOT即可(注意这里必须是大写);

    mvn deploy时会自动发布到快照版本库中;

    其他工程使用该快照版本的模块如1.0-SNAPSHOT,即使本地仓库存在该快照版本模块1.0-SNAPSHOT,maven仍会自动从私服下载最新的快照版本。

    实际上发布到快照仓库后,Version为1.0-发布时间。

 

 

转载于:https://www.cnblogs.com/badboyh2o/p/10872562.html

Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-release-plugin/2.5.3/maven-release-plugin-2.5.3.pom Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-release-plugin/2.5.3/maven-release-plugin-2.5.3.pom (11 kB at 1.0 MB/s) Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/release/maven-release/2.5.3/maven-release-2.5.3.pom Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/release/maven-release/2.5.3/maven-release-2.5.3.pom (5.0 kB at 502 kB/s) Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/maven-parent/27/maven-parent-27.pom Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/maven-parent/27/maven-parent-27.pom (41 kB at 3.7 MB/s) Downloading from central: https://repo.maven.apache.org/maven2/org/apache/apache/17/apache-17.pom Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/apache/17/apache-17.pom (16 kB at 1.5 MB/s) Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-release-plugin/2.5.3/maven-release-plugin-2.5.3.jar Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-release-plugin/2.5.3/maven-release-plugin-2.5.3.jar (53 kB at 4.1 MB/s) Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-metadata.xml Downloading from central: https://repo.maven.apache.org/maven2/org/codehaus/mojo/maven-metadata.xml Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-metadata.xml (14 kB at 1.3 MB/s) Downloaded from central: https://repo.maven.apache.org/maven2/org/codehaus/mojo/maven-metadata.xml (21 kB at 764 kB/s) [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 1.954 s [INFO] Finished at: 2025-07-09T06:18:06Z [INFO] ------------------------------------------------------------------------ [ERROR] No plugin found for prefix 'spring-boot' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/root/.m2/repository), central (https://repo.maven.apache.org/maven2)] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoPluginFoundForPrefixException root@srv771551:~/jeecg-boot# cd ../jeecgboot-vue3 -bash: cd: ../jeecgboot-vue3: No such file or directory root@srv771551:~/jeecg-boot# npm install npm run dev npm ERR! code ENOENT npm ERR! syscall open npm ERR! path /root/jeecg-boot/package.json npm ERR! errno -2 npm ERR! enoent ENOENT: no such file or directory, open '/root/jeecg-boot/package.json' npm ERR! enoent This is related to npm not being able to find a file. npm ERR! enoent npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/2025-07-09T06_18_32_236Z-debug-0.log npm ERR! code ENOENT npm ERR! syscall open npm ERR! path /root/jeecg-boot/package.json npm ERR! errno -2 npm ERR! enoent ENOENT: no such file or directory, open '/root/jeecg-boot/package.json' npm ERR! enoent This is related to npm not being able to find a file. npm ERR! enoent npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/2025-07-09T06_18_34_357Z-debug-0.log root@srv771551:~/jeecg-boot#
最新发布
07-10
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值