无法构建:获取https://registry-1.docker.io/v2/microsoft/aspnetcore/manifests/1.1:未授权:用户名或密码不正确

时间:2017-07-09 06:48:39

标签: docker asp.net-core dockerhub

我的aspnetcore docker项目构建,但是当我单击Docker按钮(或按F5)运行时我得到

Severity    Code    Description Project File    Line    Suppression State
Error   MSB4018 The "PrepareForLaunch" task failed unexpectedly.
Microsoft.DotNet.Docker.CommandLineClientException: Creating network "dockercompose1627893588_default" with the default driver
Building pswebapi
Service 'pswebapi' failed to build: Get https://registry-1.docker.io/v2/microsoft/aspnetcore/manifests/1.1: unauthorized: incorrect username or password.

For more troubleshooting information, go to http://aka.ms/DockerToolsTroubleshooting ---> Microsoft.DotNet.Docker.CommandLineClientException: Creating network "dockercompose1627893588_default" with the default driver
Building pswebapi
Service 'pswebapi' failed to build: Get https://registry-1.docker.io/v2/microsoft/aspnetcore/manifests/1.1: unauthorized: incorrect username or password
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.DotNet.Docker.DockerComposeClient.<ExecuteAsync>d__18.MoveNext()
   --- End of inner exception stack trace ---
   at Microsoft.DotNet.Docker.DockerComposeClient.<ExecuteAsync>d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.DotNet.Docker.DockerWorkspace.<PrepareForLaunchAsync>d__14.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.DotNet.Docker.BuildTasks.DockerBaseTask.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() docker-compose  C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\VisualStudio\v15.0\Docker\Microsoft.VisualStudio.Docker.Compose.targets  192 

我确实有C:使用Docker设置共享。 我正在使用Linux容器

Dockerfile是

FROM microsoft/aspnetcore:1.1
ARG source
WORKDIR /app
EXPOSE 80
COPY ${source:-obj/Docker/publish} .
ENTRYPOINT ["dotnet", "PsWebApi.dll"]

我已升级到最新的nuget包。

2 个答案:

答案 0 :(得分:8)

user id对应的 email (用于登录dockerhub )在这种情况下实际上是两件事。

需要id,用户名的 而不是email来获得images


解决

通过执行

在两者之间进行切换

> docker logout

然后在命令行上

> docker login

,然后使用您的id登录。

请注意,使用电子邮件登录后,可以在docker站点上找到id

系统将提示您输入凭据。同样,对于该用户名,请不要使用电子邮件地址。

答案 1 :(得分:1)

我在最新的ASP.NET Core模板中也面临相同的问题。以下修复程序对我有用。

  • 打开Package Manager Console窗口。
  • 运行命令docker logout

enter image description here

然后再次运行/调试(F5)该应用程序。

值得注意的是,您需要在Docker中切换到Windows容器。否则,您将看到另一个错误:image operating system "windows" cannot be used on this platform