Ensure Automatic Updates for Azure DevOps Container Images

Automatic Updates for Azure DevOps Container Images

Question

You have a project in Azure DevOps named Project1. Project1 contains a pipeline that builds a container image named Image1 and pushes Image1 to an Azure container registry named ACR1. Image1 uses a base image stored in Docker Hub.

You need to ensure that Image1 is updated automatically whenever the base image is updated.

What should you do?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

C

ACR Tasks supports automated container image builds when a container's base image is updated, such as when you patch the OS or application framework in one of your base images.

https://docs.microsoft.com/en-us/azure/container-registry/container-registry-tutorial-base-image-update

To automatically update Image1 in Azure Container Registry (ACR1) whenever its base image stored in Docker Hub is updated, you can use Docker Hub webhooks to trigger an Azure Pipeline that builds and pushes the updated Image1 to ACR1.

Here are the detailed steps to accomplish this:

  1. Add a Docker Hub service connection to Azure Pipelines
  • In Azure DevOps, go to Project Settings > Service connections.
  • Click on "New service connection" and select "Docker Registry".
  • Enter the Docker Hub registry URL, username, and password. You can also choose to use a service principal instead of username/password.
  • Test the connection and save the service connection.
  1. Create an Azure Pipeline
  • Go to the Pipelines section in Azure DevOps and create a new pipeline.
  • Choose your code repository and select the appropriate branch.
  • Select the "Docker" template to create a pipeline that builds and pushes a Docker image.
  • Edit the pipeline and add the Docker Hub service connection created in step 1 to the Docker task.
  1. Add a Docker Hub webhook
  • Go to Docker Hub and navigate to the repository containing the base image used by Image1.
  • Go to the "Webhooks" tab and click on "Create webhook".
  • Enter the URL of the Azure Pipeline created in step 2 and select the events you want to trigger the webhook (e.g. "Pushes" and "Pulls").
  • Test the webhook and save it.
  1. Configure the pipeline to build and push Image1
  • Edit the Docker task in the pipeline to use the Dockerfile for Image1 and specify the registry and image name for ACR1.
  • Save and run the pipeline to build and push the initial Image1 to ACR1.
  1. Test the automatic update
  • Make a change to the base image in Docker Hub.
  • Docker Hub will send a webhook to the Azure Pipeline, triggering it to rebuild and push the updated Image1 to ACR1.
  • Verify that the new version of Image1 is in ACR1.

Option B (Add a Docker Hub service connection to Azure Pipelines) is the correct answer, as it is the first step required to establish a connection to Docker Hub and allows Azure Pipeline to pull the base image from Docker Hub. Options A, C, and D are not correct, as they do not provide a direct solution to automatically update Image1 when its base image is updated in Docker Hub. Option A is related to events in the Azure Container Registry, which are not triggered by updates to images stored in Docker Hub. Option C is related to running tasks in ACR1, but it does not address the problem of updating Image1 automatically. Option D is a general option to set up a webhook for a project, but it does not address the specific scenario described in the question.