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-auto-purge.md
+52-28Lines changed: 52 additions & 28 deletions
Original file line number
Diff line number
Diff line change
@@ -40,7 +40,7 @@ At a minimum, specify the following when you run `acr purge`:
40
40
41
41
*`--registry` - The Azure container registry where you run the command.
42
42
*`--filter` - A repository and a *regular expression* to filter tags in the repository. Examples: `--filter "hello-world:.*"` matches all tags in the `hello-world` repository, and `--filter "hello-world:^1.*"` matches tags beginning with `1`. Pass multiple `--filter` parameters to purge multiple repositories.
43
-
*`--ago` - An expression in Go duration format to indicate a duration beyond which images are deleted. For example, `--ago 2d3h6m` selects all images last modified more than 2 days, 3 hours, and 6 minutes ago.
43
+
*`--ago` - A Go-style [duration string](https://golang.org/pkg/time/) to indicate a duration beyond which images are deleted. The duration consists of a sequence of decimal number, each with a unit suffix. Valid time units include "d" for days, "h" for hours, "m" for minutes. For example, `--ago 2d3h6m` selects all filtered images last modified more than 2 days, 3 hours, and 6 minutes ago. `--ago 1.5h` selects all filtered images last modified more than 1.5 hours ago.
44
44
45
45
`acr purge` supports several optional parameters. The following two are used in examples in this article:
46
46
@@ -53,56 +53,74 @@ For additional parameters, run `acr purge --help`.
53
53
54
54
### Run in an on-demand task
55
55
56
-
The following example uses the [az acr run][az-acr-run] command to run the `purge` command on-demand. This example deletes all image tags and manifests in the `hello-world` repository in *myregistry* that were modified more than 1 day ago. The task runs without a source context.
56
+
The following example uses the [az acr run][az-acr-run] command to run the `purge` command on-demand. This example deletes all image tags and manifests in the `hello-world` repository in *myregistry* that were modified more than 1 day ago. The container command is passed using an environment variable. The task runs without a source context.
The following example uses the [az acr task create][az-acr-task-create] command to create a daily [scheduled ACR task](container-registry-tasks-scheduled.md). The task purges tags modified more than 7 days ago in the `hello-world` repository. The task runs without a source context.
71
+
The following example uses the [az acr task create][az-acr-task-create] command to create a daily [scheduled ACR task](container-registry-tasks-scheduled.md). The task purges tags modified more than 7 days ago in the `hello-world` repository. The container command is passed using an environment variable. The task runs without a source context.
Run the [az acr task show][az-acr-task-show] command to see that the timer trigger is configured.
78
86
79
87
### Purge large numbers of tags and manifests
80
88
81
-
Purging a large number of tags and manifests could take several minutes or longer. To purge thousands of tags and manifests, the on-demand or scheduled task command might need to run longer than the default timeout time of 600 seconds for an on-demand task, or 3600 seconds for a scheduled task. In this case, pass the `--timeout` parameter to set a larger value.
89
+
Purging a large number of tags and manifests could take several minutes or longer. To purge thousands of tags and manifests, the command might need to run longer than the default timeout time of 600 seconds for an on-demand task, or 3600 seconds for a scheduled task. If the timeout time is exceeded, only a subset of tags and manifests are deleted. To ensure that a large-scale purge is complete, pass the `--timeout` parameter to increase the value.
82
90
83
-
For example, the following on-demand task times out after 3600 seconds (1 hour):
91
+
For example, the following on-demand task sets a timeout time of 3600 seconds (1 hour):
## Example: Scheduled purge of multiple repositories in a registry
94
106
95
-
This example walks through using `acr purge` to periodically clean up multiple repositories in a registry. For example, you might have a development pipeline that pushes images to the `devimage1` and `devimage2` repositories. You periodically import development images into a production repository for your deployments, so you no longer need the development images. On a weekly basis, you purge the `devimage1` and `devimage2` repositories, in preparation for the coming week's work.
107
+
This example walks through using `acr purge` to periodically clean up multiple repositories in a registry. For example, you might have a development pipeline that pushes images to the `samples/devimage1` and `samples/devimage2` repositories. You periodically import development images into a production repository for your deployments, so you no longer need the development images. On a weekly basis, you purge the `samples/devimage1` and `samples/devimage2` repositories, in preparation for the coming week's work.
96
108
97
109
### Preview the purge
98
110
99
111
Before deleting data, we recommend running an on-demand purge task using the `--dry-run` parameter. This option allows you to see the tags and manifests that the command will purge, without removing any data.
100
112
101
-
In the following example, the filter in each repository selects all tags. The `--ago 0d` parameter matches images of all ages in the repositories that match the filters. Modify the selection criteria as needed for your scenario. The `--untagged` parameter indicates to delete manifests in addition to tags.
113
+
In the following example, the filter in each repository selects all tags. The `--ago 0d` parameter matches images of all ages in the repositories that match the filters. Modify the selection criteria as needed for your scenario. The `--untagged` parameter indicates to delete manifests in addition to tags. The container command is passed to the [az acr run][az-acr-run] command using an environment variable.
@@ -136,11 +154,17 @@ Number of deleted manifests: 4
136
154
After you've verified the dry run, create a scheduled task to automate the purge. The following example schedules a weekly task on Sunday at 1:00 UTC to run the previous purge command:
0 commit comments