1 查找
docker search nexus3
2 拉取
docker pull sonatype/nexus3
3 运行
docker run -id --privileged=true --name=nexus3 --restart=always -p 85:8081 -v /root/nexus3/data:/nexus-data 0ffbaec5b098
参数解释
-id 创建守护式容器
–privileged=true 授予root权限(挂载多级目录必须为true,否则容器访问宿主机权限不足)
–name=名字 给你的容器起个名字
-p 宿主机端口:容器端口映射
-v 宿主机目录:容器目录 目录挂载(冒号前为宿主机目录,必须为绝对路径,冒号后为镜像内挂载的路径。镜像后的挂载路径为运行在容器内的程序的默认路径)
docker start nexus3
进入宿主机目录复制密码登录修改密码
cd /root/nexus3/data
vi admin.password
复制密码 登录账户名称为 admin
此地址在本地maven的settings文件编辑配置
public group是releases 和 snapshots 之和
snapshots 表示正在开发中的版本
releases 代表比较稳定的发布版本
4 配置nexus3阿里云仓库
name:
nexus_aliyun
remote_storage:
http://maven.aliyun.com/nexus/content/groups/public
保存。
并将 nexus_aliyun 配置到 maven-public
配置 maven-release,允许上传Jar包
配置本地maven
打开本地/conf/settings.xml
<profile>
<id>dev</id>
<repositories>
<repository>
<id>loacl-nexus</id>
<url>http://ip:port/repository/maven-public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>dev</activeProfile>
</activeProfiles>
<servers>
<server>
<id>maven-releases</id>
<username>xxx</username>
<password>xxx</password>
</server>
<server>
<id>maven-snapshots</id>
<username>xxx</username>
<password>xxx</password>
</server>
</servers>
另:
根据自己项目可以创建 一个 hosted repository 托管资源库, 和一个 group repository 组资源库,并提供组资源库的下载地址。
hosted repository 托管资源库:
group repository 组资源库:
可以将第三方依赖jar包上传在这里