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
+2-5Lines changed: 2 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,20 +2,17 @@
2
2
title: Purge tags and manifests
3
3
description: Use a purge command to delete multiple tags and manifests from an Azure container registry based on age and a tag filter, and optionally schedule purge operations.
4
4
ms.topic: article
5
-
ms.date: 02/19/2021
5
+
ms.date: 05/07/2021
6
6
---
7
7
8
8
# Automatically purge images from an Azure container registry
9
9
10
10
When you use an Azure container registry as part of a development workflow, the registry can quickly fill up with images or other artifacts that aren't needed after a short period. You might want to delete all tags that are older than a certain duration or match a specified name filter. To delete multiple artifacts quickly, this article introduces the `acr purge` command you can run as an on-demand or [scheduled](container-registry-tasks-scheduled.md) ACR Task.
11
11
12
-
The `acr purge` command is currently distributed in a public container image (`mcr.microsoft.com/acr/acr-cli:0.4`), built from source code in the [acr-cli](https://github.com/Azure/acr-cli) repo in GitHub.
12
+
The `acr purge` command is currently distributed in a public container image (`mcr.microsoft.com/acr/acr-cli:0.4`), built from source code in the [acr-cli](https://github.com/Azure/acr-cli) repo in GitHub.`acr purge` is currently in preview.
13
13
14
14
You can use the Azure Cloud Shell or a local installation of the Azure CLI to run the ACR task examples in this article. If you'd like to use it locally, version 2.0.76 or later is required. Run `az --version` to find the version. If you need to install or upgrade, see [Install Azure CLI][azure-cli-install].
15
15
16
-
> [!IMPORTANT]
17
-
> This feature is currently in preview. Previews are made available to you on the condition that you agree to the [supplemental terms of use][terms-of-use]. Some aspects of this feature may change prior to general availability (GA).
18
-
19
16
> [!WARNING]
20
17
> Use the `acr purge` command with caution--deleted image data is UNRECOVERABLE. If you have systems that pull images by manifest digest (as opposed to image name), you should not purge untagged images. Deleting untagged images will prevent those systems from pulling the images from your registry. Instead of pulling by manifest, consider adopting a *unique tagging* scheme, a [recommended best practice](container-registry-image-tag-version.md).
Copy file name to clipboardExpand all lines: articles/container-registry/container-registry-delete.md
+13-76Lines changed: 13 additions & 76 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,10 +2,10 @@
2
2
title: Delete image resources
3
3
description: Details on how to effectively manage registry size by deleting container image data using Azure CLI commands.
4
4
ms.topic: article
5
-
ms.date: 07/31/2019
5
+
ms.date: 05/07/2021
6
6
---
7
7
8
-
# Delete container images in Azure Container Registry using the Azure CLI
8
+
# Delete container images in Azure Container Registry
9
9
10
10
To maintain the size of your Azure container registry, you should periodically delete stale image data. While some container images deployed into production may require longer-term storage, others can typically be deleted more quickly. For example, in an automated build and test scenario, your registry can quickly fill with images that might never be deployed, and can be purged shortly after completing the build and test pass.
11
11
@@ -15,10 +15,11 @@ Because you can delete image data in several different ways, it's important to u
15
15
* Delete by [tag](#delete-by-tag): Deletes an image, the tag, all unique layers referenced by the image, and all other tags associated with the image.
16
16
* Delete by [manifest digest](#delete-by-manifest-digest): Deletes an image, all unique layers referenced by the image, and all tags associated with the image.
17
17
18
-
Sample scripts are provided to help automate delete operations.
19
-
20
18
For an introduction to these concepts, see [About registries, repositories, and images](container-registry-concepts.md).
21
19
20
+
> [!NOTE]
21
+
> After you delete image data, Azure Container Registry stops billing you immediately for the associated storage. However, the registry recovers the associated storage space using an asynchronous process. It takes some time before the registry cleans up layers and shows the updated storage usage.
22
+
22
23
## Delete repository
23
24
24
25
Deleting a repository deletes all of the images in the repository, including all tags, unique layers, and manifests. When you delete a repository, you recover the storage space used by the images that reference unique layers in that repository.
@@ -102,7 +103,7 @@ The `acr-helloworld:v2` image is deleted from the registry, as is any layer data
102
103
103
104
To maintain the size of a repository or registry, you might need to periodically delete manifest digests older than a certain date.
104
105
105
-
The following Azure CLI command lists all manifest digest in a repository older than a specified timestamp, in ascending order. Replace `<acrName>` and `<repositoryName>` with values appropriate for your environment. The timestamp could be a full date-time expression or a date, as in this example.
106
+
The following Azure CLI command lists all manifest digests in a repository older than a specified timestamp, in ascending order. Replace `<acrName>` and `<repositoryName>` with values appropriate for your environment. The timestamp could be a full date-time expression or a date, as in this example.
106
107
107
108
```azurecli
108
109
az acr repository show-manifests --name <acrName> --repository <repositoryName> \
@@ -196,85 +197,21 @@ As mentioned in the [Manifest digest](container-registry-concepts.md#manifest-di
196
197
197
198
As you can see in the output of the last step in the sequence, there is now an orphaned manifest whose `"tags"` property is an empty list. This manifest still exists within the registry, along with any unique layer data that it references. **To delete such orphaned images and their layer data, you must delete by manifest digest**.
198
199
199
-
## Delete all untagged images
200
-
201
-
You can list all untagged images in your repository using the following Azure CLI command. Replace `<acrName>` and `<repositoryName>` with values appropriate for your environment.
202
-
203
-
```azurecli
204
-
az acr repository show-manifests --name <acrName> --repository <repositoryName> --query "[?tags[0]==null].digest"
205
-
```
206
-
207
-
Using this command in a script, you can delete all untagged images in a repository.
208
-
209
-
> [!WARNING]
210
-
> Use the following sample scripts with caution--deleted image data is UNRECOVERABLE. If you have systems that pull images by manifest digest (as opposed to image name), you should not run these scripts. Deleting untagged images will prevent those systems from pulling the images from your registry. Instead of pulling by manifest, consider adopting a *unique tagging* scheme, a [recommended best practice](container-registry-image-tag-version.md).
211
-
212
-
**Azure CLI in Bash**
213
-
214
-
The following Bash script deletes all untagged images from a repository. It requires the Azure CLI and **xargs**. By default, the script performs no deletion. Change the `ENABLE_DELETE` value to `true` to enable image deletion.
The following PowerShell script deletes all untagged images from a repository. It requires PowerShell and the Azure CLI. By default, the script performs no deletion. Change the `$enableDelete` value to `$TRUE` to enable image deletion.
Azure Container Registry provides the following automated methods to remove tags and manifests, and their associated unique layer data:
267
203
204
+
* Create an ACR task that runs the `acr purge` container command to delete all tags that are older than a certain duration or match a specified name filter. Optionally configure `acr purge` to delete untagged manifests.
268
205
269
-
## Automatically purge tags and manifests (preview)
206
+
The `acr purge` container command is currently in preview. For more information, see [Automatically purge images from an Azure container registry](container-registry-auto-purge.md).
270
207
271
-
As an alternative to scripting Azure CLI commands, run an on-demand or scheduled ACR task to delete all tags that are older than a certain duration or match a specified name filter. For more information, see [Automatically purge images from an Azure container registry](container-registry-auto-purge.md).
208
+
* Optionally set a [retention policy](container-registry-retention-policy.md) for each registry, to manage untagged manifests. When you enable a retention policy, image manifests in the registry that don't have any associated tags, and the underlying layer data, are automatically deleted after a set period.
272
209
273
-
Optionally set a [retention policy](container-registry-retention-policy.md) for each registry, to manage untagged manifests. When you enable a retention policy, image manifests in the registry that don't have any associated tags, and the underlying layer data, are automatically deleted after a set period.
210
+
The retention policy is currently a preview feature of **Premium** container registries. The retention policy only applies to untagged manifests created after the policy takes effect.
274
211
275
212
## Next steps
276
213
277
-
For more information about image storage in Azure Container Registry see [Container image storage in Azure Container Registry](container-registry-storage.md).
214
+
For more information about image storage in Azure Container Registry, see [Container image storage in Azure Container Registry](container-registry-storage.md).
Copy file name to clipboardExpand all lines: articles/container-registry/container-registry-retention-policy.md
+20-18Lines changed: 20 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,35 +1,32 @@
1
1
---
2
2
title: Policy to retain untagged manifests
3
-
description: Learn how to enable a retention policy in your Azure container registry, for automatic deletion of untagged manifests after a defined period.
3
+
description: Learn how to enable a retention policy in your Premium Azure container registry, for automatic deletion of untagged manifests after a defined period.
4
4
ms.topic: article
5
-
ms.date: 10/02/2019
5
+
ms.date: 04/26/2021
6
6
---
7
7
8
8
# Set a retention policy for untagged manifests
9
9
10
-
Azure Container Registry gives you the option to set a *retention policy* for stored image manifests that don't have any associated tags (*untagged manifests*). When a retention policy is enabled, untagged manifests in the registry are automatically deleted after a number of days you set. This feature prevents the registry from filling up with artifacts that aren't needed and helps you save on storage costs. If the `delete-enabled` attribute of an untagged manifest is set to `false`, the manifest can't be deleted, and the retention policy doesn't apply.
10
+
Azure Container Registry gives you the option to set a *retention policy* for stored image manifests that don't have any associated tags (*untagged manifests*). When a retention policy is enabled, untagged manifests in the registry are automatically deleted after a number of days you set. This feature prevents the registry from filling up with artifacts that aren't needed and helps you save on storage costs.
11
11
12
12
You can use the Azure Cloud Shell or a local installation of the Azure CLI to run the command examples in this article. If you'd like to use it locally, version 2.0.74 or later is required. Run `az --version` to find the version. If you need to install or upgrade, see [Install Azure CLI][azure-cli].
13
13
14
-
A retention policy is a feature of **Premium** container registries. For information about registry service tiers, see [Azure Container Registry service tiers](container-registry-skus.md).
15
-
16
-
> [!IMPORTANT]
17
-
> This feature is currently in preview, and some [limitations apply](#preview-limitations). Previews are made available to you on the condition that you agree to the [supplemental terms of use][terms-of-use]. Some aspects of this feature may change prior to general availability (GA).
14
+
A retention policy for untagged manifests is currently a preview feature of **Premium** container registries. For information about registry service tiers, see [Azure Container Registry service tiers](container-registry-skus.md).
18
15
19
16
> [!WARNING]
20
17
> Set a retention policy with care--deleted image data is UNRECOVERABLE. If you have systems that pull images by manifest digest (as opposed to image name), you should not set a retention policy for untagged manifests. Deleting untagged images will prevent those systems from pulling the images from your registry. Instead of pulling by manifest, consider adopting a *unique tagging* scheme, a [recommended best practice](container-registry-image-tag-version.md).
21
18
22
-
## Preview limitations
23
-
24
-
* You can only set a retention policy for untagged manifests.
25
-
* The retention policy currently applies only to manifests that are untagged *after* the policy is enabled. Existing untagged manifests in the registry aren't subject to the policy. To delete existing untagged manifests, see examples in [Delete container images in Azure Container Registry](container-registry-delete.md).
26
-
27
19
## About the retention policy
28
20
29
21
Azure Container Registry does reference counting for manifests in the registry. When a manifest is untagged, it checks the retention policy. If a retention policy is enabled, a manifest delete operation is queued, with a specific date, according to the number of days set in the policy.
30
22
31
23
A separate queue management job constantly processes messages, scaling as needed. As an example, suppose you untagged two manifests, 1 hour apart, in a registry with a retention policy of 30 days. Two messages would be queued. Then, 30 days later, approximately 1 hour apart, the messages would be retrieved from the queue and processed, assuming the policy was still in effect.
32
24
25
+
If the `delete-enabled` attribute of an untagged manifest is set to `false`, the manifest is locked and is not deleted by the policy.
26
+
27
+
> [!IMPORTANT]
28
+
> The retention policy applies only to untagged manifests with timestamps *after* the policy is enabled. Untagged manifests in the registry with earlier timestamps aren't subject to the policy. For other options to delete image data, see examples in [Delete container images in Azure Container Registry](container-registry-delete.md).
29
+
33
30
## Set a retention policy - CLI
34
31
35
32
The following example shows you how to use the Azure CLI to set a retention policy for untagged manifests in a registry.
The following example sets a policy to delete any manifest in the registry as soon as it's untagged. Create this policy by setting a retention period of 0 days.
@@ -57,13 +56,14 @@ If you enable the preceding policy with a retention period of 0 days, you can qu
57
56
1. Push a test image `hello-world:latest` image to your registry, or substitute another test image of your choice.
58
57
1. Untag the `hello-world:latest` image, for example, using the [az acr repository untag][az-acr-repository-untag] command. The untagged manifest remains in the registry.
59
58
```azurecli
60
-
az acr repository untag --name myregistry --image hello-world:latest
59
+
az acr repository untag \
60
+
--name myregistry --image hello-world:latest
61
61
```
62
62
1. Within a few seconds, the untagged manifest is deleted. You can verify the deletion by listing manifests in the repository, for example, using the [az acr repository show-manifests][az-acr-repository-show-manifests] command. If the test image was the only one in the repository, the repository itself is deleted.
63
63
64
-
### Disable a retention policy
64
+
### Manage a retention policy
65
65
66
-
To see the retention policy set in a registry, run the [az acr config retention show][az-acr-config-retention-show] command:
66
+
To show the retention policy set in a registry, run the [az acr config retention show][az-acr-config-retention-show] command:
67
67
68
68
```azurecli
69
69
az acr config retention show --registry myregistry
@@ -72,12 +72,14 @@ az acr config retention show --registry myregistry
72
72
To disable a retention policy in a registry, run the [az acr config retention update][az-acr-config-retention-update] command and set `--status disabled`:
You can also set a registry's retention policy in the [Azure portal](https://portal.azure.com). The following example shows you how to use the portal to set a retention policy for untagged manifests in a registry.
82
+
You can also set a registry's retention policy in the [Azure portal](https://portal.azure.com).
0 commit comments