teckadmin.files.wordpress.com · web viewazure container service allows you to quickly deploy a...
TRANSCRIPT
Azure Container Service allows you to quickly deploy a production ready Kubernetes, DC/OS, or Docker Swarm cluster.
Azure Container Instances let you run a container in Azure without managing virtual machines and without a higher-level service.
Template
{ "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": { "location": { "type": "string" }, "containerName": { "type": "string" }, "imageType": { "type": "string", "allowedValues": [ "Public", "Private" ] },
"imageName": { "type": "string" }, "osType": { "type": "string", "allowedValues": [ "Linux", "Windows" ] }, "numberCpuCores": { "type": "string" }, "memory": { "type": "string" }, "restartPolicy": { "type": "string", "allowedValues": [ "OnFailure", "Always", "Never" ] }, "ipAddressType": { "type": "string" }, "ports": { "type": "array" }, "dnsNameLabel": { "type": "string" } }, "resources": [ { "location": "[parameters('location')]", "name": "[parameters('containerName')]", "type": "Microsoft.ContainerInstance/containerGroups", "apiVersion": "2018-10-01", "properties": { "containers": [ { "name": "[parameters('containerName')]", "properties": {
"image": "[parameters('imageName')]", "resources": { "requests": { "cpu": "[int(parameters('numberCpuCores'))]", "memoryInGB": "[float(parameters('memory'))]" } }, "ports": "[parameters('ports')]" } } ], "restartPolicy": "[parameters('restartPolicy')]", "osType": "[parameters('osType')]", "ipAddress": { "type": "[parameters('ipAddressType')]", "ports": "[parameters('ports')]", "dnsNameLabel": "[parameters('dnsNameLabel')]" } }, "tags": {} } ]}
Parameter
{ "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#", "contentVersion": "1.0.0.0", "parameters": { "containerName": { "value": "growfarmbag" }, "location": { "value": "southcentralus" }, "imageType": { "value": "Public" }, "imageName": { "value": "microsoft/aci-helloworld" },
"osType": { "value": "Linux" }, "numberCpuCores": { "value": "1" }, "memory": { "value": "1.5" }, "restartPolicy": { "value": "Never" }, "ipAddressType": { "value": "Public" }, "ports": { "value": [ { "port": "80", "protocol": "TCP" }, { "port": "445", "protocol": "TCP" } ] }, "dnsNameLabel": { "value": "mygrowfarmbag" } }}
Create from Azure CLI
az group create --name growfarm1 --location eastus
Where as the RG name growfarm1 and the location is eastus
DNS_NAME_LABEL=growfarm1bag
az container create \
--resource-group growfarm1 \
--name mycontainer \
--image microsoft/aci-helloworld \
--ports 80 \
--dns-name-label $DNS_NAME_LABEL \
--location eastus
NOTE : The image name, microsoft/aci-helloworld, refers to a Docker image hosted on Docker Hub that runs a basic Node.js web application.
az container show \
--resource-group growfarm1 \
--name mycontainer \
--query "{FQDN:ipAddress.fqdn,ProvisioningState:provisioningState}" \
--out table
FQDN ProvisioningState
------------------------------------- -------------------
growfarm1bag.eastus.azurecontainer.io Succeeded
Delete
az container delete --name mycontainer --resource-group growfarm1
Are you sure you want to perform this operation? (y/n): y
Creating containers from Azure powershell
Create a resource groupNew-AzResourceGroup -Name labrg -Location EastUS
Create a container used windows OSNote : This image packages Microsoft Internet Information Services (IIS) to run in Nano Server.
New-AzContainerGroup -ResourceGroupName labrg -Name mylabcontainer -Image mcr.microsoft.com/windows/servercore/iis:nanoserver -OsType Windows -DnsNameLabel mylab-demo-win
View the container and details Get-AzContainerGroup -ResourceGroupName labrg -Name mylabcontainer
Access it with IP or FQDN
Clean upRemove-AzContainerGroup -ResourceGroupName labrg -Name mylabcontainer
https://docs.microsoft.com/en-us/learn/modules/run-docker-with-azure-container-instances/2-run-acihttps://docs.microsoft.com/en-us/learn/modules/run-docker-with-azure-container-instances/3-restart-policieshttps://docs.microsoft.com/en-us/learn/modules/run-docker-with-azure-container-instances/4-use-environment-variableshttps://docs.microsoft.com/en-us/learn/modules/run-docker-with-azure-container-instances/5-use-data-volumeshttps://docs.microsoft.com/en-us/learn/modules/run-docker-with-azure-container-instances/6-troubleshoot-acihttps://docs.microsoft.com/en-us/cli/azure/container?view=azure-cli-latesthttps://docs.microsoft.com/en-us/azure/container-registry/container-registry-delete