快速入门:使用 Azure 门户在 Azure 中部署容器实例

使用 Azure 容器实例在 Azure 中快速方便地运行无服务器 Docker 容器。 当你不需要像 AzureKubernetes 服务这样的完整容器业务流程平台时,可以按需将应用程序部署到容器实例。

本快速入门将使用 Azure 门户部署一个独立的 Docker 容器,并使其应用程序可通过完全限定的域名 (FQDN) 使用。 在配置一些设置并部署容器后,你可以浏览到正在运行的应用程序:

App deployed using Azure Container Instances viewed in browser

登录 Azure

登录 Azure 门户

如果没有 Azure 订阅,请在开始前创建一个试用版订阅

创建容器实例

选择“+ 创建资源”,在“新建”页的搜索筛选器中键入“容器实例”

Begin creating a new container instance in the Azure portal

在搜索结果中选择“容器实例”项,然后选择“创建” 。

在“基本信息”页上,选择一个订阅,并为“资源组”、“容器名称”、“映像源”和“容器映像”输入以下值。

  • 资源组:“新建”>myresourcegroup
  • 容器名称:mycontainer
  • 映像源:快速启动映像
  • 容器映像:mcr.microsoft.com/azuredocs/aci-helloworld:latest (Linux)

Configuring basic settings for a new container instance in the Azure portal

注意

对于本快速入门,请使用默认设置来部署公共 Microsoft aci-helloworld:latest 映像。 此示例 Linux 映像打包了一个用 Node.js 编写的小型 Web 应用,该应用提供静态 HTML 页面。 还可以将自己的容器映像存储在 Azure 容器注册表、Docker Hub 或其他注册表中。

将其他值保留为默认值,然后选择“下一步: 网络”。

在“网络”页,为容器指定一个“DNS 名称标签” 。 该名称在创建容器实例的 Azure 区域中必须是唯一的。 容器将可通过 <dns-name-label>.<region>.azurecontainer.console.azure.cn 公开访问。 如果收到“DNS 名称标签不可用”错误消息,请尝试使用一个不同的 DNS 名称标签。

Configuring network settings for a new container instance in the Azure portal

将其他所有设置保留为默认设置,然后选择“查看 + 创建”。

完成验证后,将显示容器的设置摘要。 选择“创建” 提交容器部署请求。

Settings summary for a new container instance in the Azure portal

当部署启动时,会显示一个通知,指示正在进行部署。 部署了容器组后,会显示另一个通知。

通过导航到“资源组”>“myresourcegroup”>“mycontainer”打开容器组的概述 。 记下容器实例的 FQDN 及其状态。

Container group overview in the Azure portal

在其状态为“正在运行” 后,在浏览器中导航到容器的 FQDN。

App deployed using Azure Container Instances viewed in browser

祝贺你! 仅仅配置了几个设置,你便已在 Azure 容器实例中部署了一个可供公开访问的应用程序。

查看容器日志

当排查容器或其运行的应用程序的问题时,查看容器实例的日志非常有用。

若要查看容器的日志,请在“设置”下选择“容器”>“日志”。 应当会看到在浏览器中查看应用程序时生成的 HTTP GET 请求。

Container logs in the Azure portal

清理资源

完成容器后,选择 mycontainer 容器实例的“概述”,然后选择“删除”。

Deleting the container instance in the Azure portal]

在出现确认对话框时选择“是”。

Delete confirmation of a container instance in the Azure portal]

后续步骤

在本快速入门中,你已基于公共 Microsoft 映像创建了一个 Azure 容器实例。 若要基于专用 Azure 容器注册表生成容器映像并部署它,请继续学习 Azure 容器实例教程。