如何使用二头肌从Docker Hub部署到Azure App Service网站

发布于 2025-01-31 00:41:00 字数 3327 浏览 3 评论 0 原文

摘要:

我已经尝试了许多尝试在公共Dockerhub存储库中部署简单的C#jlazor映像到Azure App Service网站。使用二头肌和Azure门户的所有尝试都失败了。

目标:

在GitHub操作(CI/CD管道)内部使用二头肌从公共Dockerhub存储库中部署到Azure App Service网站。 (我也很好奇如何在门户网站上进行操作)。

什么有效:

  1. 此PowerShell命令成功地将我的DockerHub图像部署到Azure应用程序服务网站:

az.cmd webapp create -name dockerhubdeploydemo004-resource-resource-group rg_-plan basic-asp rg_ -s siegfried01 -w topSecretet -deployment-container-image-name siegfried01/demovisualStudiocicdiocicdforblazorserver

  1. 这个用于创建azure容器实例的二头肌也可以工作。

来自失败尝试的错误消息:

来自Azure Portal中的日志文件,我得到了:

2022-05-20T21:50:35.914Z ERROR - DockerApiException: Docker API responded with status code=NotFound, response={"message":"pull access denied for demovisualstudiocicdforblazorserver, repository does not exist or may require 'docker login': denied: requested access to the resource is denied"}
2022-05-20T21:50:35.915Z ERROR - Pulling docker image docker.io/demovisualstudiocicdforblazorserver failed:
2022-05-20T21:50:35.916Z WARN  - Image pull failed. Defaulting to local copy if present.
2022-05-20T21:50:35.923Z ERROR - Image pull failed: Verify docker image configuration and credentials (if using private repository)
2022-05-20T21:50:35.928Z INFO  - Stopping site dockerdeploydemo003 because it failed during startup.
/home/LogFiles/2022_05_20_lw1sdlwk000FX5_docker.log  (https://dockerdeploydemo003.scm.azurewebsites.net/api/vfs/LogFiles/2022_05_20_lw1sdlwk000FX5_docker.log)
2022-05-20T21:35:47.559Z WARN  - Image pull failed. Defaulting to local copy if present.
2022-05-20T21:35:47.562Z ERROR - Image pull failed: Verify docker image configuration and credentials (if using private repository)

<强>失败的二头肌代码:

我总是收到上述错误消息。使用二头肌代码部署后,我可以返回门户网站并查看AppSettings(DockerHub Creds&amp; url)。他们看起来正确。

参考:

  1. 不错的Dockerhub示例,但没有二头肌代码..说要使用 index.docker.io ,我尝试了(不起作用)。我还尝试使用 https://index.docker.io/v1/ 用于服务器URL,但它也无法正常工作。
  2. 不错的bicep示例,但使用ACR代替dockerhub
  3. /jamiemccrindle/bicep-app-service-container/blob/main/infra/appservice/main.bicep#l35 https://foldr.uk/azure-bicep-app-service-custom-container/“ rel =“ nofollow noreferrer”>另一个不错的二头肌示例,它使用ACR代替DockerHub 。

我很惊讶我找不到Dockerhub网站上的文档!

请帮助我更正我的二头肌代码。我怀疑我没有为DockerHub指定正确的URL或服务器。

谢谢西格弗里德

Summary:

I have made many attempts to deploy simple C# Blazor image in public DockerHub repo to Azure App Service web site. All attempts using bicep and the azure portal have failed.

Goal:

Use bicep inside of a Github action (CI/CD pipeline) to deploy from public DockerHub repo to Azure App Service Web Site. (I'm also curious as to how to do it on the portal).

What Works:

  1. This powershell command successfully deploys my DockerHub image to the Azure App Service Web site:

az.cmd webapp create --name DockerhubDeployDemo004 --resource-group rg_ --plan Basic-ASP -s siegfried01 -w topsecretet --deployment-container-image-name siegfried01/demovisualstudiocicdforblazorserver

  1. This bicep for creating an azure container instance also works.

Error Messages from Failed Attempts:

From the log files in the azure portal I get:

2022-05-20T21:50:35.914Z ERROR - DockerApiException: Docker API responded with status code=NotFound, response={"message":"pull access denied for demovisualstudiocicdforblazorserver, repository does not exist or may require 'docker login': denied: requested access to the resource is denied"}
2022-05-20T21:50:35.915Z ERROR - Pulling docker image docker.io/demovisualstudiocicdforblazorserver failed:
2022-05-20T21:50:35.916Z WARN  - Image pull failed. Defaulting to local copy if present.
2022-05-20T21:50:35.923Z ERROR - Image pull failed: Verify docker image configuration and credentials (if using private repository)
2022-05-20T21:50:35.928Z INFO  - Stopping site dockerdeploydemo003 because it failed during startup.
/home/LogFiles/2022_05_20_lw1sdlwk000FX5_docker.log  (https://dockerdeploydemo003.scm.azurewebsites.net/api/vfs/LogFiles/2022_05_20_lw1sdlwk000FX5_docker.log)
2022-05-20T21:35:47.559Z WARN  - Image pull failed. Defaulting to local copy if present.
2022-05-20T21:35:47.562Z ERROR - Image pull failed: Verify docker image configuration and credentials (if using private repository)

Failing Bicep Code:

I tried exporting the ARM code from the successful powershell deployment and the failed portal attempts and converting it to bicep. In both cases the code was very similar. In both cases I had to add/edit the app settings containing the dockerhub URL, account and password. I always received the above error messages. After deploying using bicep code, I could go back into the portal and view the appsettings (dockerhub creds & URL). They looked correct.

References:

  1. Nice DockerHub example but no bicep code.. Says to use index.docker.io for the server and I tried that (did not work). I also tried using https://index.docker.io/v1/ for the server URL and that did not work either.
  2. Nice Bicep Example but uses ACR instead of DockerHub
  3. Another nice Bicep Example that uses ACR instead of DockerHub.

I was surprised I could not find the documentation on the DockerHub site!

Please help me correct my bicep code. I suspect I'm not specifying the correct URL or server for DockerHub.

Thanks

Siegfried

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

如梦初醒的夏天 2025-02-07 00:41:00
  1. 我找不到Dockerhub上的网页,该网页提供了我正在寻找的详细信息(如URL)。但是,docker info命令如下所述非常有帮助。

  2. 此二头肌代码为我带来了困难(在GitHub上的二头肌支持的一些帮助下):

var appConfigNew = {
  DOCKER_ENABLE_CI: 'true'
  DOCKER_REGISTRY_SERVER_PASSWORD: dockerhubPassword
  DOCKER_REGISTRY_SERVER_URL: 'https://index.docker.io/v1/'
  DOCKER_REGISTRY_SERVER_USERNAME: dockerUsername
}

resource appSettings 'Microsoft.Web/sites/config@2021-01-15' = {
  name: 'appsettings'
  parent: web
  properties: appConfigNew
}
  1. 最后,我通过反复试验发现了这一点:
      linuxFxVersion: 'DOCKER|${dockerUsername}/demovisualstudiocicdforblazorserver:${tag}'

哇!我真的为此努力了!

  1. I could not find the web page on Dockerhub that gave the detailed information I was looking for (like the URL). However, the docker Info command as described here was very helpful.

  2. This bicep code did the trick for me (with some help from the bicep support on github):

var appConfigNew = {
  DOCKER_ENABLE_CI: 'true'
  DOCKER_REGISTRY_SERVER_PASSWORD: dockerhubPassword
  DOCKER_REGISTRY_SERVER_URL: 'https://index.docker.io/v1/'
  DOCKER_REGISTRY_SERVER_USERNAME: dockerUsername
}

resource appSettings 'Microsoft.Web/sites/config@2021-01-15' = {
  name: 'appsettings'
  parent: web
  properties: appConfigNew
}
  1. And lastly, I discovered this by trial and error:
      linuxFxVersion: 'DOCKER|${dockerUsername}/demovisualstudiocicdforblazorserver:${tag}'

Wow! I really worked hard for this one!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文