1.搜索nexus
docker search nexus
2.拉取nexus镜像
docker pull docker.io/sonatype/nexus3
3.创建挂载目录
mkdir -p /kerwin/install/nexus3/nexus-data
chown -R 200 /kerwin/install/nexus3/nexus-data/
4.运行启动
docker run -tid -p 8081:8081 --name nexus -e NEXUS_CONTEXT=nexus -v /kerwin/install/nexus3/nexus-data:/nexus-data docker.io/sonatype/nexus3
5.查看状态
docker ps -a 查看容器内运行所有
docker logs 1798c2879c25 查看日志
6.登录nexus,默认账号admin,密码通过查看cat nexus-data/admin.password。
http://ip:8081/nexus/
默认仓库说明
maven-central:maven中央库,默认从https://repo1.maven.org/maven2/拉取jar
maven-releases:私库发行版jar,初次安装请将Deployment policy设置为Allow redeploy
maven-snapshots:私库快照(调试版本)jar
maven-public:仓库分组,把上面三个仓库组合在一起对外提供服务,在本地maven基础配置settings.xml或项目pom.xml中使用
7.创建代理,设置 ==> create repository ==> maven2(proxy) ==> name , remote storage , maximum metadata age
Name: aliyun
Remote storage : http://maven.aliyun.com/nexus/content/groups/public
Maximum metadata age : 288000 设置200天
8.添加jar到nexus
8.1 通过nexus浏览器添加
8.2 通过maven推送jar推送.
pom.xml
<distributionManagement>
<repository>
<id>maven-local-release</id>
<url>http://ip:8081/nexus/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>maven-local-snapshots</id>
<url>http://ip:8081/nexus/repository/maven-releases/</url>
</snapshotRepository>
</distributionManagement>
settings.xml
<server>
<id>maven-local-release</id>
<username>admin</username>
<password>password</password>
</server>
<server>
<id>maven-local-snapshots</id>
<username>admin</username>
<password>password</password>
</server>
执行:mvn deploy,需要重复添加包,修改Deployment policy 为 Allow redeploy
9.添加jar包到本地仓库
mvn install:install-file -Dfile=《这个地方填写你本地的jar》 -DgroupId=<这个对应组织> -DartifactId=<对应分支> -Dversion=《这个地方填写版本》 -Dpackaging=jar