# Set the organization default

Choose the lifecycle rules every repository without its own policy runs, and whether they delete, only preview, or do nothing.

The default applies to every repository in `inherit` mode. It has three modes: `active` (the hourly
run deletes what it selects), `preview` (it only reports) and `off`. The default takes
`ews-lifecycle/v1` only; an AWS ECR policy is accepted per repository, not here.

**Warning:**
Enabling the default deletes images in every repository that uses it, from the next hourly run.

## Prerequisites

- Permission for `ecr:PutLifecyclePolicy` on `rn:ews::<organization id>:ecr:lifecycle-default/image`.
  Without it the console shows the rules read-only and the **Status** buttons disabled.
- To open the page and run its dry run: `ecr:GetLifecyclePolicy` on the same; without it the
  console's **Lifecycle defaults** page shows a refusal.

## Change the rules or the mode

**Console**
1. Open **Container registry**, then choose **Lifecycle defaults**.
2. Under **Rules**, edit the rules, then choose **Save rules**. Saving keeps the current mode.
   While rule changes are unsaved, the **Status** buttons are disabled ("Save or discard your rule
   changes first.").
3. Under **Status**, choose **Enable**, check the number in the button, then choose
   **Enable: delete … images now**. Or choose **Switch to preview** or **Switch off**; these save
   at once.

**Dry run: what these rules would do now** lists every image of every repository that uses the
default, and **Per repository** how much each would lose. **Repositories with their own setting**
lists the ones that do not use the default.

**CLI**
```sh
dcloud ecr lifecycle-defaults preview --policy @default.json
dcloud ecr lifecycle-defaults put --policy @default.json --mode active
```

**API**
```http
PUT /ecr/api/lifecycle-defaults
{ "policy": { "version": "ews-lifecycle/v1", "rules": [ { "id": "untagged", "priority": 1, "select": { "tagStatus": "untagged" }, "when": { "all": [ { "sinceCreatedDays": 7 } ] } } ], "keep": { "newest": 10 }, "softDeleteDays": 7 }, "mode": "active" }
```

## Result

The answer says what the saved default would delete now across the repositories that use it:
`wouldExpire` (count and bytes), the 50 repositories with the most bytes to expire, and up to
5,000 images with their decision (`totalImages` counts all).

An organization created before 2026-11-17 has the platform's default as a preview until someone
enables it; newer organizations have it active.

## If it is refused

`400` `A default keeps expired images restorable for at least a day; 0 is only for a repository’s own policy`
when `softDeleteDays` is 0.

## Related

- [Lifecycle policies](lifecycle-policies.md)
- [Set a lifecycle policy](set-a-lifecycle-policy.md)
- `ecr.lifecycle-defaults.put` · `dcloud ecr lifecycle-defaults put`
