Lab 10: Run a container in seconds¶
At a glance
- Time: about 20 minutes
- Region: Southeast Asia
- You create: 1 container instance (0.5 CPU, 0.5 GB)
- Cost: a few cents an hour while it exists. Delete it at the end.
What you will learn¶
- What Azure Container Instances (ACI) is: the quickest way to run a container, with no servers to manage.
- How to run a container from a public image and reach it from the internet.
- How to read the container's logs and how to stop and start it.
What is different in this environment
- You run in Southeast Asia, in your own resource group.
- You make the container small: 0.5 CPU and 0.5 GB. Larger sizes cost more, and the lab limit is 2 CPU and 4 GB.
- You turn off container logs to Log Analytics, because that workspace bills per GB. You still read the logs from the container itself.
- You use a public image. Private registries aren't part of this lab.
Before you start¶
- You are signed in to the lab directory (Getting started).
- Your lab resource group is
rg-CLOUD-LAB-GRP-N. ReplaceNwith your group number. - Delete the VMs and the scale set from Lab 08, if you still have them.
- Each group may have only 1 container instance.
Task 1: Deploy a container instance¶
- Search for Container instances and select + Create.
-
On Basics:
Setting Value Resource group rg-CLOUD-LAB-GRP-NContainer name lab-c1Region Southeast Asia SKU Standard Image source Quickstart images Image mcr.microsoft.com/azuredocs/aci-helloworld:latest (Linux) -
Select Change size and set Number of CPU cores to
0.5and Memory (GiB) to0.5. Select OK. -
Select Next: Networking. Set DNS name label to
aci-grp-N-plus 5 random letters or digits, for exampleaci-grp-12-k7x3q.The label must be unique
Your container is reached at
<label>.southeastasia.azurecontainer.io. If you see DNS name label not available, change the label. -
Select Next: Monitoring. Clear the box Enable container instance logs.
- Select Next: Advanced and take the defaults. Select Review + create, then Create. This takes 2 to 3 minutes.
Keep it small
A container with more than 2 CPU or 4 GB, a Spot container or a GPU container is blocked with [LAB-P09A-CONTAINER-INSTANCE].
Task 2: Test the container¶
- Select Go to resource. On the Overview page, check that Status is Running.
- Copy the FQDN, open it in a new browser tab and check that you see Welcome to Azure Container Instances. Refresh a few times.
- Back in the portal, under Settings, select Containers, then Logs.
- You should see lines for the web requests from your browser.
Think about it
The container has a public address and no firewall in front of it. What would you do before putting a real application on it?
Task 3: Stop, start and see the guardrail¶
Stop and start¶
- On the Overview page, select Stop and confirm. Wait until the status is Stopped, and try the FQDN. It no longer answers.
- Select Start. When the status is Running, the FQDN answers again.
Try a size that isn't allowed¶
- Search for Container instances and select + Create.
- Use your resource group, the name
lab-c2, the quickstart image, and Change size to4CPU cores. - Go to Review + create. The validation fails with a message that starts with
[LAB-P09A-CONTAINER-INSTANCE]. Read it. - Close the form without creating anything.
Why you don't create it
Each group may have only 1 container instance. A second one that passes validation would be deleted automatically a few minutes later. This step only shows you the size rule.
Task 4: Clean up¶
- Open
lab-c1and select Delete. Confirm. - Check that your resource group has no container instance left.
Check your work¶
-
lab-c1was Running, and its FQDN showed the welcome page. - The logs showed your web requests.
- A 4-CPU container was blocked with
[LAB-P09A-CONTAINER-INSTANCE]. - Your resource group is empty again.
Key points¶
- ACI runs a container directly, with no VM or cluster to manage. You pay per second for the CPU and memory you request.
- Size matters: request only what the container needs.
- A container group has a public address only if you give it a DNS label.
- Stop containers when you don't need them, and delete them when you finish.