LoongLee's blog

Nexus使用指南

Nexus使用指南

来源

原始文档: nexus使用.md

核心内容

Sonatype Nexus Repository Manager 是开源的仓库管理器,支持多种包格式。

简介

Nexus 支持: - Maven - Java 依赖管理 - npm - Node.js 包管理 - Docker - 容器镜像仓库 - PyPI - Python 包 - NuGet - .NET 包 - Raw - 通用文件存储

部署方式

Docker 部署

docker run -d -p 8081:8081 \
  --name nexus \
  -v nexus-data:/nexus-data \
  sonatype/nexus3

默认配置

  • 端口: 8081
  • 管理员密码: 初次启动时自动生成 bash docker exec nexus cat /nexus-data/admin.password

仓库类型

类型 说明
hosted 私有仓库,上传内部组件
proxy 代理远程仓库,缓存依赖
group 组合多个仓库,统一入口

Maven 配置示例

<settings>
  <mirrors>
    <mirror>
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>http://nexus:8081/repository/maven-public/</url>
    </mirror>
  </mirrors>
</settings>

npm 配置示例

npm config set registry http://nexus:8081/repository/npm-group/

Docker 配置

# 登录
 docker login nexus:8082

# 推送镜像
docker tag myimage nexus:8082/myrepo/myimage:tag
docker push nexus:8082/myrepo/myimage:tag

# 拉取镜像
docker pull nexus:8082/myrepo/myimage:tag

关键要点

  • Nexus 3 支持 Docker 私有仓库
  • 使用 group 仓库统一代理多个源
  • 支持 blob 存储后端(S3、文件系统等)
  • 提供细粒度的权限控制

相关实体

  • Nexus - 仓库管理器
  • Maven - Java 构建工具
  • npm - Node.js 包管理器
  • Docker - 容器化平台
  • 仓库管理 - 制品库管理