设为首页 收藏本站
查看: 834|回复: 0

[经验分享] Docker and Nexus

[复制链接]

尚未签到

发表于 2017-12-6 16:32:51 | 显示全部楼层 |阅读模式
  目的:运用docker和Nexus来搭建私服Maven仓库
  过程:
  1、安装docker,然后通过docker来下载Nexus image,运行docker命令:



docker pull sonatype/nexus3
  有些由于权限问题需要加sudo来运行。
  2、因为我要和本地文件夹挂载,所以先建立本地文件夹,并将要挂载的文件夹的owner改为200,如下:



mkdir /angusyang/nexus/nexus-data
chown -R 200 /angusyang/nexus/nexus-data
  3、用docker运行nexus服务,如下:



docker run -d -p 6130:8081 --name nexus -v /angusyang/nexus/nexus-data:/nexus-data sonatype/nexus3
  这里简单说明,-p 后面是端口映射,冒号前面的是本地机器的端口,后面的是nexus抛出的端口;-v 是挂载,冒号前面是本地路径,后面是nexus的共享路径。
  4、运行正常后http访问服务器及端口应该能看到Nexus的界面,并对Nexus进行相关配置,例如:http://localhost:6130
  登陆进去后配置相关信息,默认的管理员账号:admin,密码:admin123
DSC0000.png

  在上图可以新增配置仓库来源等等,另外可以在maven-public中加入你想要访问的仓库,有优先顺序,前面的找不到才会去后面的仓库继续找,例如:
DSC0001.png

  其他权限等等配置就不在此说明了,另外简单说明一下,我建立了一个maven-3rd-central仓库,改仓库是存放maven仓库找不到的一些第三方的jar,简单列出推送jar到该仓库的命令(该命令要配置maven的settings.xml文件后执行):



mvn deploy:deploy-file
-DgroupId=com.tibco
-DartifactId=jms
-Dversion=2.0
-Dpackaging=jar
-Dfile=D:\jms-2.0.jar
-Durl=http://localhost:6130/repository/maven-3rd-central/
-DrepositoryId=nexus
  5、配置maven的settings.xml文件,例如:



<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>D:/apache_maven_3_5_0/repository</localRepository>
<servers>
<server>
<id>nexus</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>
<mirrors>
<mirror>
<!--This sends everything else to /public -->
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://eellnx34.eel1.esquel.com:6130/repository/maven-public/</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<!--Enable snapshots for the built in central repo to direct -->
<!--all requests to nexus via the mirror -->
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>
  6、我们在开发时,也需要对pom.xml文件进行配置,以便将打包的jar上传到私服中去,例如:



<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.angusyang</groupId>
<artifactId>test-nexus</artifactId>
<version>1.0-SNAPSHOT</version>
<distributionManagement>
<repository>
<id>nexus</id>
<name>Releases</name>
<url>http://localhost:6130/repository/maven-releases</url>
</repository>
<snapshotRepository>
<id>nexus</id>
<name>Snapshot</name>
<url>http://localhost:6130/repository/maven-snapshots</url>
</snapshotRepository>
</distributionManagement>
......
</project>
  这样基本就配置完成了,其他的就是Nexus的一些配置了,这里就不讲述了!

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-421383-1-1.html 上篇帖子: Docker镜像管理 下篇帖子: Removing Docker Containers and Images
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表