1、shell输入
- docker run -dti \
- --net=host \
- --name=nexus3 \
- --privileged=true \
- --restart=always \
- --ulimit nofile=655350 \
- --ulimit memlock=-1 \
- --memory=1G \
- --memory-swap=-1 \
- -e INSTALL4J_ADD_VM_PARAMS="-Xms512m -Xmx512m -XX:MaxDirectMemorySize=1g" \
- -v /etc/localtime:/etc/localtime \
- -v /data/nexus3:/nexus-data \
- -p 8081:8081 --privileged=true \
- sonatype/nexus3
2、查看nexus日志,看到Started Sonatype Nexus OSS 表示启动好了
docker logs -f nexus3
3、查看密码
cat /data/nexus3/admin.password
登录 http://ip:8081 账号:admin 密码就是刚才看到的。
4、登录后的配置看这里
Docker 安装 nexus_银狐的技术博客_51CTO博客
5、java maven项目pom.xml配置
在pom.xml文件中配置 distributionManagement 节点如下,在项目中执行deploy命令后,jar包将会被上传到nexus中,
默认地,maven编译打包不会下载SNAPSHOT版本的jar包,所以还需要在pom.xml文件中配置支持下载snapshot版本jar包,
- <distributionManagement>
- <repository>
- <id>liledapu_hosted</id>
- <!--release版本仓库-->
- <name>Nexus Release Repository</name>
- <!--hosted地址址-->
- <url>http://xx:8081/repository/liledapu_hosted/</url>
- </repository>
- <snapshotRepository>
- <id>liledapu_snapshots</id>
- <!--snapshot版本仓库-->
- <name>Nexus Snapshot Repository</name>
- <url>http://xx:8081/repository/liledapu_snapshots/</url>
- </snapshotRepository>
- </distributionManagement>
-
- <repositories>
- <repository>
- <id>liledapu_group</id>
- <url>http://xx:8081/repository/liledapu_group/</url>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
- </repository>
- </repositories>
6、maven 的setting.xml(apache-maven-3.9.0\conf目录下)添加配置,liledapu为配置的组名
- <servers>
- <server>
- <id>liledapu_group</id>
- <username>name</username>
- <password>password</password>
- </server>
- <server>
- <id>liledapu_hosted</id>
- <username>name</username>
- <password>password</password>
- </server>
- <server>
- <id>liledapu_snapshots</id>
- <username>name</username>
- <password>password</password>
- </server>
-
- </servers>
-
-
-
-
- <mirrors>
-
- <mirror>
- <id>liledapu_group</id>
- <mirrorOf>central</mirrorOf>
- <name>liledapu_group 私域</name>
- <url>http://xxxxx:8081/repository/liledapu_group/</url>
- </mirror>
-
- <mirror>
- <id>aliyunmaven</id>
- <mirrorOf>*</mirrorOf>
- <name>阿里云公共仓库</name>
- <url>https://maven.aliyun.com/repository/public</url>
- </mirror>
- </mirrors>
到此就可以了