nexus3配置docker匿名拉取

原创
半兽人 发表于: 2019-11-19   最后更新时间: 2019-11-20 19:23:57  
{{totalSubscript}} 订阅, 4,212 游览

需求

希望任何人都可以直接匿名(anonymous)拉取那Nexus3上部署的镜像,无需docker login

版本说明

例子1中版本:nexus-3.19.1-01
版本2中版本:nexus-3.12.1-01

运行nexus3

## 拉取最新的
curl -SLO https://sonatype-download.global.ssl.fastly.net/nexus/3/latest-unix.tar.gz

## 拉取指定版本的 3.19.1-01
curl -SLO https://sonatype-download.global.ssl.fastly.net/repository/repositoryManager/3/nexus-3.19.1-01-unix.tar.gz

## 拉取指定版本的 3.19.1-01
curl -SLO https://sonatype-download.global.ssl.fastly.net/repository/repositoryManager/3/nexus-3.12.1-01-unix.tar.gz

## 解压运行
tar -C /data/nexus3 -xf nexus-3.19.1-01-unix.tar.gz
export RUN_AS_USER=root
/data/nexus3/nexus-3.12.1-01/bin/nexus start

创建Blob

例一(nexus-3.19.1-01)

Nexus令我有些头疼,直到我发现一个不太明显的声明帖子,指出不要更改匿名领域(anonymous realm)。

因此,按照以下步骤进行操作:

  1. 创建 docker(proxy)仓库 (例如:hub.docker.com)

  2. 启用 HTTP/HTTPS (取决于您是使用ssl还是使用反向代理)

  3. 启用 "Allow anonymous docker pull (Docker Bearer Token Realm required)"

  4. "Location of the remote repository" (docker-hub)” 输入 "https://registry-1.docker.io"

  5. 设置 "Docker Index" ("Use Docker Hub”)

  6. save(保存)

确保匿名用户有权读取新的repository(默认的匿名角色是允许对更多内容进行读取访问的,此时匿名应该已经可以pull了)

另外,如果想尽可能地限制匿名用户(即:仅允许docker pull),则创建一个角色“nx-docker_read”(或类似名称),并将其赋予"nx-repository-view-docker--read"*。 (这将允许组中的任何用户从任何docker存储库中pull镜像,从而允许匿名pull,但在Web界面上看不到任何提示)

然后,剩下的就是将匿名用户的组更改为新角色(在我的示例中为“nx-docker_read”),并将其从“nx-anonymous” => anon-users中删除,仍可以pull镜像。

例二(nexus-3.12.1-01)

允许设置通过匿名的方式拉取镜像。

screenshot

然后需要在Realms主页激活Docker Bearer Token Reamlm,如下图所示:
screenshot

即可

更新于 2019-11-20

查看nexus更多相关的文章或提一个关于nexus的问题,也可以与我们一起分享文章