在 Docker Hub 上发布 .Net Core Web 应用程序时出错

Error in Publishing .Net Core Web App on Docker Hub

我正在学习 docker 和容器。我正在尝试通过 visual studio 2019 在 Docker Hub 上发布我的 .Net Core 3.1 Web 应用程序。我在 Windows PC 上,但是 visual studio 部署环境设置为 Linux 和 Docker 也设置为 Linux。我也安装了 WSL2(linux 2 的 Windows 子系统)。此外,Web 应用程序运行良好,同时我可以看到容器和图像已成功创建到 Docker 仪表板 (运行ning) 中。但是,在尝试将其发布到 Docker Hub 时,出现以下错误。

你能帮我看看我的 PC 上缺少哪个部分吗(它是 azure windows 10 VM)?

注意: 我也可以 运行 linux 容器,没有任何问题。另外 Ubuntu 20 是从 Windows 商店安装的。

2021-07-01 10:19:58 AM
Microsoft.WebTools.Azure.Publish.Docker.DockerCommandException: Running the docker.exe tag command failed.

Current context "desktop-linux" is not found on the file system, please check your config file at C:\Users\kulkarnis009\AppData\Local\Temp61a412d485473395194d8ad39fe785\config.json
   at Microsoft.WebTools.Azure.Publish.Docker.DockerOperations.ThrowDockerCommandError(String dockerCommand)
   at Microsoft.WebTools.Azure.Publish.Docker.DockerOperations.<DockerTagAsync>d__3.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.WebTools.Azure.Publish.Docker.DockerPublish.<DockerPublishAsync>d__2.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.WebTools.Azure.Publish.ContainerRegistry.ManageContainerRegistry.<PushImageAsync>d__11.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.WebTools.Azure.Publish.PublishProviders.ContainerRegistryProfileVisual.<PostPublishAsync>d__38.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.Publish.Framework.Nexus.PublishProfilesServiceImpl.ServerProjectProfilesManager.<RunPublishTaskAsync>d__53.MoveNext()

===================

我有同样的问题,我可以通过使用以下命令将 docker 上下文切换回默认值(它被设置为桌面-linux)来解决:

docker context use default

在文件中

file:///C:/Users/UserName/AppData/Local/Temp/c69e796a148440f18675b80111e06796/config.json

更改桌面-linux

{
  "auths": {},
  "credsStore": "desktop",
  "currentContext": "default",
  "stackOrchestrator": "swarm",
  "HttpHeaders": {
    "X-Meta-Source-Client": "vs/web/publish"
  }
}

currentContext 有 desktop-linux,我只是放了“default”

为 Windows 3.4.0 恢复到 Docker 对我有用。

在此处下载: https://docs.docker.com/docker-for-windows/release-notes/#docker-desktop-340

这里讨论了这个错误: https://github.com/docker/for-win/issues/11530 https://developercommunity.visualstudio.com/t/unable-to-publish-to-acr-running-the-dockerexe-tag/1464650 https://developercommunity.visualstudio.com/t/current-context-desktop-linux-is-not-found-on-the/1463380