You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/container-registry/container-registry-tasks-overview.md
+8-9Lines changed: 8 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,18 +1,18 @@
1
1
---
2
-
title: Automate OS and framework patching with Azure Container Registry Tasks (ACR Tasks)
3
-
description: An introduction to ACR Tasks, a suite of features in Azure Container Registry that provides secure, automated container image build and patching in the cloud.
2
+
title: Automate building and patching container images with Azure Container Registry Tasks (ACR Tasks)
3
+
description: An introduction to ACR Tasks, a suite of features in Azure Container Registry that provides secure, automated container image build, management, and patching in the cloud.
4
4
services: container-registry
5
5
author: dlepow
6
6
7
7
ms.service: container-registry
8
8
ms.topic: article
9
-
ms.date: 05/20/2019
9
+
ms.date: 06/12/2019
10
10
ms.author: danlep
11
11
---
12
12
13
-
# Automate OS and framework patching with ACR Tasks
13
+
# Automate container image builds and maintenance with ACR Tasks
14
14
15
-
Containers provide new levels of virtualization, isolating application and developer dependencies from infrastructure and operational requirements. What remains, however, is the need to address how this application virtualization is patched.
15
+
Containers provide new levels of virtualization, isolating application and developer dependencies from infrastructure and operational requirements. What remains, however, is the need to address how this application virtualization is managed and patched over the container lifecycle.
16
16
17
17
## What is ACR Tasks?
18
18
@@ -42,8 +42,7 @@ The following table shows a few examples of supported context locations for ACR
42
42
| Local filesystem | Files within a directory on the local filesystem. |`/home/user/projects/myapp`|
43
43
| GitHub master branch | Files within the master (or other default) branch of a GitHub repository. |`https://github.com/gituser/myapp-repo.git`|
44
44
| GitHub branch | Specific branch of a GitHub repo.|`https://github.com/gituser/myapp-repo.git#mybranch`|
45
-
| GitHub PR | Pull request in a GitHub repo. |`https://github.com/gituser/myapp-repo.git#pull/23/head`|
46
-
| GitHub subfolder | Files within a subfolder in a GitHub repo. Example shows combination of PR and subfolder specification. |`https://github.com/gituser/myapp-repo.git#pull/24/head:myfolder`|
45
+
| GitHub subfolder | Files within a subfolder in a GitHub repo. Example shows combination of a branch and subfolder specification. |`https://github.com/gituser/myapp-repo.git#mybranch:myfolder`|
47
46
| Remote tarball | Files in a compressed archive on a remote webserver. |`http://remoteserver/myapp.tar.gz`|
48
47
49
48
ACR Tasks is designed as a container lifecycle primitive. For example, integrate ACR Tasks into your CI/CD solution. By executing [az login][az-login] with a [service principal][az-login-service-principal], your CI/CD solution could then issue [az acr build][az-acr-build] commands to kick off image builds.
@@ -61,7 +60,7 @@ Learn how to trigger builds on source code commit in the second ACR Tasks tutori
61
60
62
61
## Automate OS and framework patching
63
62
64
-
The power of ACR Tasks to truly enhance your container build workflow comes from its ability to detect an update to a base image. When the updated base image is pushed to your registry, ACR Tasks can automatically build any application images based on it.
63
+
The power of ACR Tasks to truly enhance your container build workflow comes from its ability to detect an update to a base image. When the updated base image is pushed to your registry, or a base image is updated in a public repo such as in Docker Hub, ACR Tasks can automatically build any application images based on it.
65
64
66
65
Container images can be broadly categorized into *base* images and *application* images. Your base images typically include the operating system and application frameworks upon which your application is built, along with other customizations. These base images are themselves typically based on public upstream images, for example: [Alpine Linux][base-alpine], [Windows][base-windows], [.NET][base-dotnet], or [Node.js][base-node]. Several of your application images might share a common base image.
67
66
@@ -72,7 +71,7 @@ Because ACR Tasks dynamically discovers base image dependencies when it builds a
72
71
Learn about OS and framework patching in the third ACR Tasks tutorial, [Automate image builds on base image update with Azure Container Registry Tasks](container-registry-tutorial-base-image-update.md).
73
72
74
73
> [!NOTE]
75
-
> Base image updates trigger builds only when both the base and application images reside in the same Azure container registry, or the base resides in a public Docker Hub repository.
74
+
> Currently, base image updates trigger builds only when both the base and application images reside in the same Azure container registry, or the base resides in a public Docker Hub or Microsoft Container Registry repository.
Copy file name to clipboardExpand all lines: articles/container-registry/container-registry-tutorial-base-image-update.md
+40-17Lines changed: 40 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ author: dlepow
6
6
7
7
ms.service: container-registry
8
8
ms.topic: tutorial
9
-
ms.date: 09/24/2018
9
+
ms.date: 06/12/2019
10
10
ms.author: danlep
11
11
ms.custom: "seodec18, mvc"
12
12
# Customer intent: As a developer or devops engineer, I want container
@@ -68,17 +68,31 @@ A base image is often updated by the image maintainer to include new features or
68
68
69
69
When a base image is updated, you're presented with the need to rebuild any container images in your registry based on it to include the new features and fixes. ACR Tasks includes the ability to automatically build images for you when a container's base image is updated.
70
70
71
+
### Tasks triggered by a base image update
72
+
73
+
* Currently, for image builds from a Dockerfile, an ACR task detects dependencies on base images in the same Azure container registry, a public Docker Hub repo, or a public repo in Microsoft Container Registry. If the base image specified in the `FROM` statement resides in one of these locations, the ACR task adds a hook to ensure the image is rebuilt any time its base is updated.
74
+
75
+
* When you create an ACR task with the [az acr task create][az-acr-task-create] command, by default the task is *enabled* for trigger by a base image update. That is, the `base-image-trigger-enabled` property is set to True. If you want to disable this behavior in a task, update the property to False. For example, run the following [az acr task update][az-acr-task-update] command:
76
+
77
+
```azurecli
78
+
az acr task update --myregistry --name mytask --base-image-trigger-enabled False
79
+
```
80
+
81
+
* To enable an ACR task to determine and track a container image's dependencies -- which include its base image -- you must first trigger the task **at least once**. For example, trigger the task manually using the [az acr task run][az-acr-task-run] command.
82
+
83
+
* To trigger a task on base image update, the base image must have a *stable* tag, such as `node:9-alpine`. This tagging is typical for a base image that is updated with OS and framework patches to a latest stable release. If the base image is updated with a new version tag, it does not trigger a task. For more information about image tagging, see the [best practices guidance](https://blogs.msdn.microsoft.com/stevelasker/2018/03/01/docker-tagging-best-practices-for-tagging-and-versioning-docker-images/).
84
+
71
85
### Base image update scenario
72
86
73
-
This tutorial walks you through a base image update scenario. The [code sample][code-sample] includes two Dockerfiles: an application image, and an image it specifies as its base. In the following sections, you create an ACR task that automatically triggers a build of the application image when a new version of the base image is pushed to your container registry.
87
+
This tutorial walks you through a base image update scenario. The [code sample][code-sample] includes two Dockerfiles: an application image, and an image it specifies as its base. In the following sections, you create an ACR task that automatically triggers a build of the application image when a new version of the base image is pushed to the same container registry.
74
88
75
89
[Dockerfile-app][dockerfile-app]: A small Node.js web application that renders a static web page displaying the Node.js version on which it's based. The version string is simulated: it displays the contents of an environment variable, `NODE_VERSION`, that's defined in the base image.
76
90
77
91
[Dockerfile-base][dockerfile-base]: The image that `Dockerfile-app` specifies as its base. It is itself based on a [Node][base-node] image, and includes the `NODE_VERSION` environment variable.
78
92
79
93
In the following sections, you create a task, update the `NODE_VERSION` value in the base image Dockerfile, then use ACR Tasks to build the base image. When the ACR task pushes the new base image to your registry, it automatically triggers a build of the application image. Optionally, you run the application container image locally to see the different version strings in the built images.
80
94
81
-
In this tutorial, your ACR task builds and pushes a single container image specified in a Dockerfile. ACR Tasks can also run [multi-step tasks](container-registry-tasks-multi-step.md), using a YAML file to define steps to build, push, and optionally test multiple containers.
95
+
In this tutorial, your ACR task builds and pushes an application container image specified in a Dockerfile. ACR Tasks can also run [multi-step tasks](container-registry-tasks-multi-step.md), using a YAML file to define steps to build, push, and optionally test multiple containers.
82
96
83
97
## Build the base image
84
98
@@ -107,21 +121,17 @@ az acr task create \
107
121
> [!IMPORTANT]
108
122
> If you previously created tasks during the preview with the `az acr build-task` command, those tasks need to be re-created using the [az acr task][az-acr-task] command.
109
123
110
-
This task is similar to the quick task created in the [previous tutorial](container-registry-tutorial-build-task.md). It instructs ACR Tasks to trigger an image build when commits are pushed to the repository specified by `--context`.
111
-
112
-
Where it differs is in its behavior, in that it also triggers a build of the image when its *base image* is updated. The Dockerfile specified by the `--file` argument, [Dockerfile-app][dockerfile-app], supports specifying an image from within the same registry as its base:
124
+
This task is similar to the quick task created in the [previous tutorial](container-registry-tutorial-build-task.md). It instructs ACR Tasks to trigger an image build when commits are pushed to the repository specified by `--context`. While the Dockerfile used to build the image in the previous tutorial specifies a public base image (`FROM node:9-alpine`), the Dockerfile in this task, [Dockerfile-app][dockerfile-app], specifies a base image in the same registry:
113
125
114
126
```Dockerfile
115
127
FROM ${REGISTRY_NAME}/baseimages/node:9-alpine
116
128
```
117
129
118
-
When you run a task, ACR Tasks detects an image's dependencies. If the base image specified in the `FROM` statement resides within the same registry or a public Docker Hub repository, it adds a hook to ensure this image is rebuilt any time its base is updated.
130
+
This configuration makes it easy to simulate a framework patch in the base image later in this tutorial.
119
131
120
132
## Build the application container
121
133
122
-
To enable ACR Tasks to determine and track a container image's dependencies--which include its base image--you **must** first trigger its task **at least once**.
123
-
124
-
Use [az acr task run][az-acr-task-run] to manually trigger the task and build the application image:
134
+
Use [az acr task run][az-acr-task-run] to manually trigger the task and build the application image. This step ensures that the task tracks the application image's dependency on the base image.
125
135
126
136
```azurecli-interactive
127
137
az acr task run --registry $ACR_NAME --name taskhelloworld
@@ -133,22 +143,28 @@ Once the task has completed, take note of the **Run ID** (for example, "da6") if
133
143
134
144
If you're working locally (not in the Cloud Shell), and you have Docker installed, run the container to see the application rendered in a web browser before you rebuild its base image. If you're using the Cloud Shell, skip this section (Cloud Shell does not support `az acr login` or `docker run`).
135
145
136
-
First, log in to your container registry with [az acr login][az-acr-login]:
146
+
First, authenticate to your container registry with [az acr login][az-acr-login]:
137
147
138
148
```azurecli
139
149
az acr login --name $ACR_NAME
140
150
```
141
151
142
-
Now, run the container locally with `docker run`. Replace **\<run-id\>** with the Run ID found in the output from the previous step (for example, "da6").
152
+
Now, run the container locally with `docker run`. Replace **\<run-id\>** with the Run ID found in the output from the previous step (for example, "da6"). This example names the container `myapp` and includes the `--rm` parameter to remove the container when you stop it.
143
153
144
-
```azurecli
145
-
docker run -d -p 8080:80 $ACR_NAME.azurecr.io/helloworld:<run-id>
154
+
```bash
155
+
docker run -d -p 8080:80 --name myapp --rm $ACR_NAME.azurecr.io/helloworld:<run-id>
146
156
```
147
157
148
158
Navigate to `http://localhost:8080` in your browser, and you should see the Node.js version number rendered in the web page, similar to the following. In a later step, you bump the version by adding an "a" to the version string.
149
159
150
160
![Screenshot of sample application rendered in browser][base-update-01]
151
161
162
+
To stop and remove the container, run the following command:
163
+
164
+
```bash
165
+
docker stop myapp
166
+
```
167
+
152
168
## List the builds
153
169
154
170
Next, list the task runs that ACR Tasks has completed for your registry using the [az acr task list-runs][az-acr-task-list-runs] command:
@@ -220,7 +236,7 @@ If you'd like to perform the following optional step of running the newly built
220
236
If you're working locally (not in the Cloud Shell), and you have Docker installed, run the new application image once its build has completed. Replace `<run-id>` with the RUN ID you obtained in the previous step. If you're using the Cloud Shell, skip this section (Cloud Shell does not support `docker run`).
221
237
222
238
```bash
223
-
docker run -d -p 8081:80 $ACR_NAME.azurecr.io/helloworld:<run-id>
239
+
docker run -d -p 8081:80 --name updatedapp --rm $ACR_NAME.azurecr.io/helloworld:<run-id>
224
240
```
225
241
226
242
Navigate to http://localhost:8081 in your browser, and you should see the updated Node.js version number (with the "a") in the web page:
@@ -229,6 +245,12 @@ Navigate to http://localhost:8081 in your browser, and you should see the update
229
245
230
246
What's important to note is that you updated your **base** image with a new version number, but the last-built **application** image displays the new version. ACR Tasks picked up your change to the base image, and rebuilt your application image automatically.
231
247
248
+
To stop and remove the container, run the following command:
249
+
250
+
```bash
251
+
docker stop updatedapp
252
+
```
253
+
232
254
## Clean up resources
233
255
234
256
To remove all resources you've created in this tutorial series, including the container registry, container instance, key vault, and service principal, issue the following commands:
@@ -257,8 +279,9 @@ In this tutorial, you learned how to use a task to automatically trigger contain
0 commit comments