Примечание
Для доступа к этой странице требуется авторизация. Вы можете попробовать войти или изменить каталоги.
Для доступа к этой странице требуется авторизация. Вы можете попробовать изменить каталоги.
Use Azure Container Instances to run serverless Docker containers in Azure with simplicity and speed. Развертывайте приложение в экземпляре контейнера по требованию, когда вам не нужна полнофункциональная платформа оркестрации контейнеров, такая как Azure Kubernetes Service. In this quickstart, you use an Azure Resource Manager template (ARM template) to deploy an isolated Docker container and make its web application available with a public IP address.
Шаблон Azure Resource Manager — это файл нотации объектов JavaScript (JSON), который определяет инфраструктуру и конфигурацию проекта. В шаблоне используется декларативный синтаксис. Вы описываете предполагаемое развертывание без написания последовательности команд программирования для создания развертывания.
Если среда соответствует предварительным требованиям и вы знакомы с использованием шаблонов ARM, нажмите кнопку Развертывание в Azure. На портале Azure откроется шаблон.
Предпосылки
Если у вас нет подписки Azure, создайте бесплатную учетную запись, прежде чем приступить к работе.
Проверьте шаблон
Шаблон, используемый в этом кратком руководстве, взят из шаблонов быстрого запуска Azure.
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.26.54.24096",
"templateHash": "15999594271314721416"
}
},
"parameters": {
"name": {
"type": "string",
"defaultValue": "acilinuxpublicipcontainergroup",
"metadata": {
"description": "Name for the container group"
}
},
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Location for all resources."
}
},
"image": {
"type": "string",
"defaultValue": "mcr.microsoft.com/azuredocs/aci-helloworld",
"metadata": {
"description": "Container image to deploy. Should be of the form repoName/imagename:tag for images stored in public Docker Hub, or a fully qualified URI for other registries. Images from private registries require additional registry credentials."
}
},
"port": {
"type": "int",
"defaultValue": 80,
"metadata": {
"description": "Port to open on the container and the public IP address."
}
},
"cpuCores": {
"type": "int",
"defaultValue": 1,
"metadata": {
"description": "The number of CPU cores to allocate to the container."
}
},
"memoryInGb": {
"type": "int",
"defaultValue": 2,
"metadata": {
"description": "The amount of memory to allocate to the container in gigabytes."
}
},
"restartPolicy": {
"type": "string",
"defaultValue": "Always",
"allowedValues": [
"Always",
"Never",
"OnFailure"
],
"metadata": {
"description": "The behavior of Azure runtime if container has stopped."
}
}
},
"resources": [
{
"type": "Microsoft.ContainerInstance/containerGroups",
"apiVersion": "2023-05-01",
"name": "[parameters('name')]",
"location": "[parameters('location')]",
"properties": {
"containers": [
{
"name": "[parameters('name')]",
"properties": {
"image": "[parameters('image')]",
"ports": [
{
"port": "[parameters('port')]",
"protocol": "TCP"
}
],
"resources": {
"requests": {
"cpu": "[parameters('cpuCores')]",
"memoryInGB": "[parameters('memoryInGb')]"
}
}
}
}
],
"osType": "Linux",
"restartPolicy": "[parameters('restartPolicy')]",
"ipAddress": {
"type": "Public",
"ports": [
{
"port": "[parameters('port')]",
"protocol": "TCP"
}
]
}
}
}
],
"outputs": {
"name": {
"type": "string",
"value": "[parameters('name')]"
},
"resourceGroupName": {
"type": "string",
"value": "[resourceGroup().name]"
},
"resourceId": {
"type": "string",
"value": "[resourceId('Microsoft.ContainerInstance/containerGroups', parameters('name'))]"
},
"containerIPv4Address": {
"type": "string",
"value": "[reference(resourceId('Microsoft.ContainerInstance/containerGroups', parameters('name')), '2023-05-01').ipAddress.ip]"
},
"location": {
"type": "string",
"value": "[parameters('location')]"
}
}
}
The following resource is defined in the template:
- Microsoft.ContainerInstance/containerGroups: create an Azure container group. This template defines a group consisting of a single container instance.
More Azure Container Instances template samples can be found in the quickstart template gallery.
Развертывание шаблона
Выберите следующее изображение, чтобы войти на портал Azure и открыть шаблон. The template creates a registry and a replica in another location.
Введите или выберите следующие значения.
- Подписка. Выберите нужную подписку Azure.
- Группа ресурсов. Щелкните Создать, введите уникальное имя новой группы ресурсов и щелкните ОК.
- Location: select a location for the resource group. Пример: центральная часть США.
- Name: accept the generated name for the instance, or enter a name.
- Image: accept the default image name. Этот пример образа Linux содержит небольшое веб-приложение Node.js, которое обслуживает статические HTML-страницы.
Accept default values for the remaining properties.
Review the terms and conditions. If you agree, select I agree to the terms and conditions stated above.
After the instance successfully creates, you get a notification:
Для развертывания шаблона используется портал Azure. Кроме портала Azure, вы можете использовать Azure PowerShell, Azure CLI и REST API. Дополнительные сведения о других методах развертывания см. в статье о развертывании с использованием шаблонов.
Проверка развернутых ресурсов
Use the Azure portal or a tool such as the Azure CLI to review the properties of the container instance.
In the portal, search for Container Instances, and select the container instance you created.
On the Overview page, note the Status of the instance and its IP address.
Once its status is Running, navigate to the IP address in your browser.
Просмотр журналов контейнеров
Просмотр журналов для экземпляра контейнера помогает устранять неполадки с этим контейнером или запущенными в нем приложениями.
Чтобы просмотреть журналы контейнера, в разделе Параметры щелкните Контейнеры>Журналы. Вы увидите запрос HTTP GET, созданный при просмотре приложения в браузере.
Очистка ресурсов
When you're done with the container, on the Overview page for the container instance, select Delete. При появлении запроса подтвердите удаление.
Дальнейшие действия
In this quickstart, you created an Azure container instance from a public Microsoft image. Если вы хотите создать образ контейнера и развернуть его из частного реестра контейнеров Azure, ознакомьтесь с руководством по Azure Container Instances.
Пошаговые инструкции по созданию шаблона см. в следующей статье: