在Fedora 25中,Docker出现了“尝试登录https://hub.docker.com/v2/时失败,状态为404未找到”的错误。

14

我已经在 Fedora 25 中安装了 Docker CE。

当我尝试使用以下命令登录到 Docker Hub 时,出现错误。

$ docker login --username xxx --password yyy https://hub.docker.com/
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
Error response from daemon: login attempt to 
https://hub.docker.com/v2/ failed with status: 404 Not Found

$ docker --version
 Docker version 17.07.0-ce, build 8784753

$ docker-machine --version
 docker-machine version 0.12.2, build 9371605

请注意,在Ubuntu 16.04中同样的命令可以正常工作。唯一我能想到的区别是Ubuntu有Docker,而Fedora有Docker-CE。

不确定为什么我只在Fedora上遇到这个错误。当Fedora安装在VirtualBox虚拟机中时,我会遇到这个错误。

7个回答

20

当Registry为hub.docker.com时,您无需指定它。

docker login --username xxx --password yyy

不带URL使用上述命令,它应该可以正常工作。


1
当我没有指定DockerHub URL时,出现了以下错误。错误内容为 ----> 来自守护程序的错误响应: 获取 https://registry-1.docker.io/v2/:未授权: 用户名或密码不正确。 - Rajkumar Natarajan
尝试在其他操作系统上使用相同的用户名和密码,看看是否有效。 - Tarun Lalwani
是的。它在Ubuntu 16.04上运行正常,但在Fedora 25上失败了。 - Rajkumar Natarajan
当然。我会做到的。 - Rajkumar Natarajan

4

当我为一个Docker应用程序设置Jenkins流水线时,遇到了类似的问题。

问题在于Jenkinsfile中的构建阶段使用https://hub.docker.com作为Docker的注册表。

stage('Push image') {
  /* Finally, we'll push the image with two tags:
  * First, the incremental build number from Jenkins
  * Second, the 'latest' tag.
  * Pushing multiple tags is cheap, as all the layers are reused. */
  docker.withRegistry('https://hub.docker.com', 'Dockerhub') {
    app.push("${env.BUILD_NUMBER}")
    app.push("latest")
  }
}
以下是我修复它的方法
我只需将 docker 仓库https://hub.docker.com 修改为 https://registry.hub.docker.com 即可。
stage('Push image') {
  /* Finally, we'll push the image with two tags:
  * First, the incremental build number from Jenkins
  * Second, the 'latest' tag.
  * Pushing multiple tags is cheap, as all the layers are reused. */
  docker.withRegistry('https://registry.hub.docker.com', 'Dockerhub') {
    app.push("${env.BUILD_NUMBER}")
    app.push("latest")
  }
}

然后在我的Jenkins配置中,需要填写Dockerhub凭证:

username: my_username (not my email address)
password: my_password

就是这样。

希望这有所帮助


这个解决方案对我来说突然失效了。但是我找到了这篇文档:https://appfleet.com/blog/building-docker-images-to-docker-hub-using-jenkins-pipelines/它基本上告诉我们要将空字符串作为docker-registry参数使用。 如果你仔细想一想,这是有道理的。 - tobi42
守护程序错误响应:获取“https://registry.hub.docker.com/v2/”时出错:未授权:用户名或密码不正确。 - AgentFire

3

Docker Hub是默认的注册表,因此无需指定注册表(即只需使用docker login --username ....就足够了)。

然而,你收到此错误的原因是hub.docker.com是Docker Hub网站的域名,而不是支持Docker Hub的注册表;注册表位于index.docker.io上(例如,docker login index.docker.io)。

简而言之,像下面这样运行命令:

PS D:> docker login 使用Docker ID登录以从Docker Hub推送和拉取映像。如果您没有Docker ID,请前往https://hub.docker.com创建一个。 用户名: 密码: 登录成功 PS D:>


2
根据无法登录Docker Hub的讨论, 可能注册表仅实现了V1(或未配置为使用V2规范,这种情况下必须配置守护程序以支持旧版注册表)。

您可以通过"docker info"命令验证:

docker info
...
Server Version: 17.09.0-ce
Operating System: Ubuntu 16.04.3 LTS
...
Registry: https://index.docker.io/v1/

因此,它失败了...
docker login --username my_login --password my_password
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
Error response from daemon: Get https://registry-1.docker.io/v2/: unauthorized: incorrect username or password

MaxReglisse - 我在运行于虚拟机中的Fedora 25中遇到了问题,但在主机上运行的Ubuntu 16.10中没有问题。当我运行命令docker info时,结果是相同的(Registry: https://index.docker.io/v1/)。我不确定为什么它在Ubuntu中可以工作,但在Fedora中却不能。有什么建议吗? - Rajkumar Natarajan
MaxReglisse - 有关我上一条评论,您有什么建议吗? - Rajkumar Natarajan

0

您可以使用Tarun提到的上述命令,或者将参数缩写为-u表示用户名和-p表示密码。

以下是Docker登录的基本截图

enter image description here


0

如先前所述,您无需指定注册表。 但需要注意的是,CLI不会像Docker Hub页面那样将用户名转换为小写。只需执行以下操作:

docker login --username <username-in-all-lowercase> --password <xxxxxx>

然后你就可以开始了。

如果失败,请尝试删除或重命名〜/ .docker / config.json CLI配置文件。


0

输入以下命令:

docker login

然后输入您的用户名和密码

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接