从私有 Nexus 存储库中提取图像或为图像执行 docker-compose 时“没有基本身份验证凭据”

mmr*_*raj 9 docker docker-compose

我想把问题及其解决方案放在这里,因为我在从私有 Nexus 存储库中提取图像时遇到了这个问题,但我无法找到明确的解决方案。

问题

我可以访问私有 Nexus 存储库,我可以对其进行验证,但转到 Nexus 存储库门户并登录。我已经在我的 mac 上安装了 Docker,并尝试从上面的 Nexus 存储库门户中提取图像。

类似于下面的内容(其中redis-dev1是存储库中的图像名称)

docker pull nexusrepo.domain.com:8343/redis-dev1 
Run Code Online (Sandbox Code Playgroud)

当我这样做时:我收到以下错误:

Error response from daemon: Get https://nexusrepo.domain.com:8343/redis-dev1/manifests/1:
no basic auth credentials
Run Code Online (Sandbox Code Playgroud)

mmr*_*raj 11

分辨率

诀窍是:设置/配置我们的本地 docker 以使用远程仓库。

通常为了测试我们的本地 docker,我们使用某种本地 repo。

但在这里我们试图将我们的本地 docker 连接到外部存储库。因此,我们必须进行 docker 登录,以便将本地 docker 配置为使用该 repo。

在执行 docker pull 之前,我使用以下命令对 nexus 存储库进行了 docker 登录。

docker login nexusrepo.domain.com:8343 --username <nexusrepo-username> --password <nexusrepo-password>
Run Code Online (Sandbox Code Playgroud)

这给了我

WARNING! Using --password via the CLI is insecure. Use --password-stdin.
Login Succeeded
Run Code Online (Sandbox Code Playgroud)

在此之后,我重试了 docker pull 命令并下载了图像。

$ docker pull nexusrepo.domain.com:8343/redis-dev1
1: Pulling from redis-dev1
a3edc43aeb02: Pull complete 
e3238738e1ef: Pull complete 
d4cf32a6f41d: Pull complete 
0c23342da3f1: Pull complete 
7f0e234e3192: Pull complete 
4411116da4fd: Pull complete 
557a23268824: Pull complete 
3cd234e1b6e8: Pull complete 
Digest: sha256:7bc1 .... 
Status: Downloaded newer image for nexusrepo.domain.com:8343/redis-dev1
nexusrepo.domain.com:8343/redis-dev1
Run Code Online (Sandbox Code Playgroud)

现在本地 docker repo 设置为使用远程 repo。这可以用于任何外部回购。

希望这可以帮助和我一样的人:)

  • 不要使用`--password`,然后它会询问。 (6认同)