Skip to content

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
  • Labs icon Lab
  • A Cloud Guru
Azure icon
Labs

Run Containers by Using Azure Container Instances

In this lab, you will get some practice with both Azure Container Instances and Azure Container Registry. First, you’ll jump into Azure Cloud Shell to create an Azure Container Registry. Then, you will add a simple Docker container image to the registry. Once the container image is pushed to the registry, you will move to the Azure portal to run an instance of the container in Azure Container Instances. To be successful completing the lab on your own, you should be familiar with the Azure portal and Azure CLI, but anyone with an interest in learning more about these two services for containerized code can use the lab guide and solution videos to work through the objectives successfully.

Azure icon
Labs

Path Info

Level
Clock icon Intermediate
Duration
Clock icon 1h 15m
Published
Clock icon May 18, 2023

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

Table of Contents

  1. Challenge

    Housekeeping

    1. Open an incognito or in-private window, and log in to the Azure portal using the username and password provided in the lab environment.
    2. From within the portal, initiate the Cloud Shell, and when prompted, select a Bash shell (versus PowerShell).
    3. When prompted, choose "Mount a Storage Account."
    4. Choose the lab subscription and click Apply.
    5. Select the storage account that's already been deployed for you.
    6. Select the one, existing, resource group.
    7. Create a new fileshare and name it "fileshare" (all lower-case)
    8. Click Apply.
    9. Wait for the command prompt to appear.
  2. Challenge

    Create an Instance of Azure Container Registry (ACR)

    From the Bash command prompt in Cloud Shell:

    1. Retrieve the name of the resource group already deployed in the lab environment using the az group list command, and copy the name of the resource group.

    2. Set up three variables as follows:

      rg=<SOURCE_GROUP_NAME>
      name=acrlabdemo
      acr="$name$RANDOM"
      
    3. Set up a new ACR using the az acr create command. You will need to pass arguments for the resource group, the name of the new ACR, and the service tier, or SKU. Hint: Use the rg and acr environment variables for the first two arguments, and set the SKU to Basic. This step may take several minutes to complete.

    4. Enable an admin user for the registry using the az acr update command. You will need to pass arguments for the ACR name (using the acr environment variable) and then set the admin-enabled argument to true.

  3. Challenge

    Build and Push a Container Image to ACR

    You should still be in the Cloud Shell session you had opened when creating the ACR instance.

    1. Change to the clouddrive directory with cd clouddrive.

    2. Create a simple, one-line Dockerfile, called "Dockerfile" with the command, below, which will create the file in your clouddrive directory.

      echo FROM mcr.microsoft.com/hello-world > Dockerfile
      
    3. Build (and push) a new imagine in your ACR, using the Dockerfile you just created using the az acr build command. You will need to pass three arguments: the image, the registry name, and the Dockerfile name.

      Hints: The value for the --image argument is sample/hello-world:v1. After the argument for the Dockerfile name, add a space and then a period ("."); the period indicates that the file can be found at the root of the current directory, which is clouddrive. If you leave out the period, you will likely get an error. The build and push will take a few minutes to complete.

    4. Close or minimize the Cloud Shell, and return to the resource group overview page in the portal.

    5. Find and select the new ACR instance and go to Repositories to confirm that the image exists in the repository.

  4. Challenge

    Deploy an Image to Azure Container Instances (ACI)

    In the Azure portal, create a new ACI. Ensure that you:

    1. Assign it to the existing resource group; do not create a new one.
    2. Leave the region defaulted, and name your container anything you wish.
    3. Use the image stored in your ACR.

      Hint: Once you select Azure Container Registry for the Image Source, it should default to your ACR and the sample image. If not, see the troubleshooting tips, below.

    4. Skip all other tabs in the wizard, and proceed to review and create the ACI. It will take a few minutes to deploy.
    5. Go to the resource and select Start. You can monitor the start-up progress in Notifications.
    6. When the container has started, navigate to Containers and click Logs to confirm that your installation is working.

    Troubleshooting:

    • When working through the ACI wizard, if the ACR and image do not appear automatically when you choose Azure Container Registry for the Image Source, you may need to refresh the admin access (which you did at the command line earlier in the lab). To do that in the portal, return to the ACR Overview page, and select Update near the top of the page. Toggle the Admin user to Disabled and Save. Then, toggle the Admin user back to Enabled and Save again. Return to the ACI wizard, and you should see the ACR and the sample image available in the registry and image fields.
    • When you start your container in ACI, you may get an error message that says the container is "still transitioning." Wait a couple of minutes and try again.

The Cloud Content team comprises subject matter experts hyper focused on services offered by the leading cloud vendors (AWS, GCP, and Azure), as well as cloud-related technologies such as Linux and DevOps. The team is thrilled to share their knowledge to help you build modern tech solutions from the ground up, secure and optimize your environments, and so much more!

What's a lab?

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Provided environment for hands-on practice

We will provide the credentials and environment necessary for you to practice right within your browser.

Guided walkthrough

Follow along with the author’s guided walkthrough and build something new in your provided environment!

Did you know?

On average, you retain 75% more of your learning if you get time for practice.

Start learning by doing today

View Plans