快速入门:使用 Azure 门户在 Azure 中部署容器实例Quickstart: Deploy a container instance in Azure using the Azure portal

使用 Azure 容器实例在 Azure 中快速方便地运行无服务器 Docker 容器。Use Azure Container Instances to run serverless Docker containers in Azure with simplicity and speed. 当你不需要像 AzureKubernetes 服务这样的完整容器业务流程平台时,可以按需将应用程序部署到容器实例。Deploy an application to a container instance on-demand when you don't need a full container orchestration platform like Azure Kubernetes Service.

本快速入门将使用 Azure 门户部署一个独立的 Docker 容器,并使其应用程序可通过完全限定的域名 (FQDN) 使用。In this quickstart, you use the Azure portal to deploy an isolated Docker container and make its application available with a fully qualified domain name (FQDN). 在配置一些设置并部署容器后,你可以浏览到正在运行的应用程序:After configuring a few settings and deploying the container, you can browse to the running application:

在浏览器中显示的使用 Azure 容器实例部署的应用

登录 AzureSign in to Azure

通过 https://portal.azure.cn 登录到 Azure 门户。Sign in to the Azure portal at https://portal.azure.cn.

如果没有 Azure 订阅,可在开始前创建一个试用帐户If you don't have an Azure subscription, create a trial account before you begin.

创建容器实例Create a container instance

选择“+ 创建资源”,在“新建”页的搜索筛选器中键入“容器实例”。Select the + Create a resource , type Container Instances in search filter of New page.

![开始在 Azure 门户中创建新的容器实例][aci-portal-01]![Begin creating a new container instance in the Azure portal][aci-portal-01]

在市场结果中选择“容器实例”项。Select the Container Instances item in marketplace result.

在“基本信息”页的“资源组”、“容器名称”和“容器映像”文本框中输入以下值 。On the Basics page, enter the following values in the Resource group, Container name, and Container image text boxes. 将其他值保留为默认值,然后选择“确定” 。Leave the other values at their defaults, then select OK.

  • 资源组:“新建” > myresourcegroupResource group: Create new > myresourcegroup
  • 容器名称:mycontainerContainer name: mycontainer
  • 映像源:快速启动映像Image source: Quickstart images
  • 容器映像:mcr.microsoft.com/azuredocs/aci-helloworld (Linux)Container image: mcr.microsoft.com/azuredocs/aci-helloworld (Linux)

在 Azure 门户中配置新的容器实例的基本设置

对于本快速入门,请使用默认设置来部署公共 Microsoft aci-helloworld 映像。For this quickstart, you use default settings to deploy the public Microsoft aci-helloworld image. 此示例 Linux 映像打包了一个用 Node.js 编写的小型 Web 应用,该应用提供静态 HTML 页面。This sample Linux image packages a small web app written in Node.js that serves a static HTML page. 还可以将自己的容器映像存储在 Azure 容器注册表、Docker Hub 或其他注册表中。You can also bring your own container images stored in Azure Container Registry, Docker Hub, or other registries.

在“网络”页,为容器指定一个“DNS 名称标签” 。On the Networking page, specify a DNS name label for your container. 该名称在创建容器实例的 Azure 区域中必须是唯一的。The name must be unique within the Azure region where you create the container instance. 容器将可通过 <dns-name-label>.<region>.azurecontainer.console.azure.cn 公开访问。Your container will be publicly reachable at <dns-name-label>.<region>.azurecontainer.console.azure.cn. 如果收到“DNS 名称标签不可用”错误消息,请尝试使用一个不同的 DNS 名称标签。If you receive a "DNS name label not available" error message, try a different DNS name label.

在 Azure 门户中配置新容器实例的网络设置

将其他设置保留为默认设置,然后选择“查看 + 创建” 。Leave the other settings at their defaults, then select Review + create.

完成验证后,将显示容器的设置摘要。When the validation completes, you're shown a summary of the container's settings. 选择“创建” 提交容器部署请求。Select Create to submit your container deployment request.

Azure 门户中新的容器实例的设置摘要

当部署启动时,会显示一个通知,指出正在进行部署。When deployment starts, a notification appears to indicate the deployment is in progress. 部署了容器组后,会显示另一个通知。Another notification is displayed when the container group has been deployed.

通过导航到“资源组” > “myresourcegroup” > “mycontainer”打开容器组的概述 。Open the overview for the container group by navigating to Resource Groups > myresourcegroup > mycontainer. 记下容器实例的 FQDN(完全限定的域名)及其 状态Take note of the FQDN (the fully qualified domain name) of the container instance, as well its Status.

Azure 门户中的容器组概述

在其 状态 为“正在运行” 后,在浏览器中导航到容器的 FQDN。Once its Status is Running, navigate to the container's FQDN in your browser.

在浏览器中显示的使用 Azure 容器实例部署的应用

祝贺你!Congratulations! 仅仅配置了几个设置,你便已在 Azure 容器实例中部署了一个可供公开访问的应用程序。By configuring just a few settings, you've deployed a publicly accessible application in Azure Container Instances.

查看容器日志View container logs

当排查容器或其运行的应用程序的问题时,查看容器实例的日志非常有用。Viewing the logs for a container instance is helpful when troubleshooting issues with your container or the application it runs.

若要查看容器的日志,请在“设置” 下选择“容器” ,然后选择“日志” 。To view the container's logs, under Settings, select Containers, then Logs. 应当会看到在浏览器中查看应用程序时生成的 HTTP GET 请求。You should see the HTTP GET request generated when you viewed the application in your browser.

Azure 门户中的容器日志

清理资源Clean up resources

完成容器后,选择 mycontainer 容器实例的“概述”,然后选择“删除”。 When you're done with the container, select Overview for the mycontainer container instance, then select Delete.

删除 Azure 门户中的容器实例

在出现确认对话框时选择“是”。 Select Yes when the confirmation dialog appears.

Azure 门户中容器实例的删除确认

后续步骤Next steps

在本快速入门中,你已基于公共 Microsoft 映像创建了一个 Azure 容器实例。In this quickstart, you created an Azure container instance from a public Microsoft image. 若要基于专用 Azure 容器注册表生成容器映像并部署它,请继续学习 Azure 容器实例教程。If you'd like to build a container image and deploy it from a private Azure container registry, continue to the Azure Container Instances tutorial.