在Azure App Service Linux上部署Docker容器

时间:2018-10-04 07:46:31

标签: docker docker-compose azure-web-app-service azure-container-registry

我有一个构建为docker image(ubuntu)的简单应用,并将其放入docker容器中。它没有附加任何卷。我想将此容器推送到Azure AppService Linux。我尝试了几种选择,但没有成功。

  1. Azure CLI创建一个Web应用程序,并将容器推送到Azure容器注册表,然后将其部署到Web应用程序。

    给出<div class="field-wrap"> @Html.TextBoxFor(model => model.Username, new { @class = "form-control", id = "SignupUsername" , placeholder = "Username", @required = "required", autofocus = "" }) @Html.ValidationMessageFor(model => model.Username, "", new { @class = "text-danger" }) </div> 错误。

  2. 将容器上载到invalid reference format,并更新了Web应用程序容器设置以将该容器加载到Web应用程序中。

    给出acrimage not found错误。

不确定如何进行此操作。非常感谢您的帮助。我也想知道如何在这里对卷使用永久性存储。 Azure invalid reference format是更好的选择,但不确定如何将其映射到容器路径。

下面是我的示例fileshare文件。

docker-compose

3 个答案:

答案 0 :(得分:1)

使用上面描述的目的地,首先应在本地运行映像,以检查其是否正常运行。您应该检查本地计算机中是否存在与撰写文件相关的图像。

如果要将图像推送到Azure容器注册表并从该图像部署Web应用程序。您可以从Use a custom Docker image for Web App for Containers获取有关这些步骤的更多详细信息。

我认为,如果您只有一项要部署的服务,则可以使用Dockerfile代替docker compose文件。无论使用docker映像还是Azure Web App服务,部署都更加简单。而docker compose对于多服务更有用。

答案 1 :(得分:1)

图像参考必须采用以下格式: 图片:服务器名称 .azurecr.io / 图片名称标签

除此以外,我推荐此常见问题解答,它对我的​​应用程序启动和运行有很大帮助: https://docs.microsoft.com/en-us/azure/app-service/containers/app-service-linux-faq#custom-containers

答案 2 :(得分:0)

以下是将Azure存储安装到多容器WebApp的方法(使用docker-compose.yml):

#Sample Docker Compose:
version: '3.3'

services:
   web:
     image: appsvc/python
     ports:
       - "8000:8000"
     volumes:
       - test:/home/site/wwwroot/test

volume:
     - test

路径映射

enter image description here

(“ test”是我们在docker-compose.yml中使用的自定义ID)

文件存储

enter image description here

我们现在可以从webapp容器中查看存储中的目录:

enter image description here

https://github.com/MicrosoftDocs/azure-docs/blob/master/articles/app-service/containers/how-to-serve-content-from-azure-storage.md